Complete the code to plot a normalized histogram using matplotlib.
import matplotlib.pyplot as plt data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] plt.hist(data, density=[1]) plt.show()
Setting density=True normalizes the histogram so the area sums to 1.
Complete the code to plot a normalized histogram with 5 bins.
import matplotlib.pyplot as plt values = [5, 7, 7, 8, 9, 10, 10, 10, 11] plt.hist(values, bins=[1], density=True) plt.show()
Setting bins=5 divides the data into 5 equal-width bins.
Fix the error in the code to correctly plot a normalized histogram.
import matplotlib.pyplot as plt scores = [60, 70, 70, 80, 90, 90, 90, 100] plt.hist(scores, bins=4, [1]=True) plt.show()
The correct parameter to normalize histograms in matplotlib is density.
Fill both blanks to create a normalized histogram with 6 bins and blue color.
import matplotlib.pyplot as plt ages = [22, 25, 25, 30, 35, 35, 40, 45, 50] plt.hist(ages, bins=[1], density=[2], color='blue') plt.show()
Use bins=6 to set six bins and density=True to normalize the histogram.
Fill all three blanks to create a normalized histogram with red color, 4 bins, and alpha transparency 0.7.
import matplotlib.pyplot as plt weights = [55, 60, 65, 70, 75, 80, 85, 90] plt.hist(weights, bins=[1], density=[2], color=[3], alpha=0.7) plt.show()
Set bins=4 for four bins, density=True to normalize, and color='red' for red bars.
