Complete the code to import the matplotlib plotting library.
import [1] as plt
We import the pyplot module from matplotlib as plt to create plots.
Complete the code to create two lists of data for histograms.
data1 = [1, 2, 3, 4, 5] data2 = [1]
We create a second list of numbers to overlay a second histogram.
Fix the error in the code to plot the first histogram with 5 bins.
plt.hist(data1, bins=[1])
plt.show()The bins parameter expects an integer, not a string or list.
Fill both blanks to plot two histograms overlayed with transparency.
plt.hist(data1, bins=[1], alpha=[2]) plt.hist(data2, bins=5, alpha=0.5) plt.show()
We use 5 bins and alpha=0.5 for transparency to see both histograms clearly.
Fill all three blanks to add labels and a legend to the overlayed histograms.
plt.hist(data1, bins=5, alpha=0.5, label=[1]) plt.hist(data2, bins=5, alpha=0.5, label=[2]) plt.[3]() plt.show()
Labels name each histogram, and plt.legend() shows the legend on the plot.
