Complete the code to plot a cumulative histogram using matplotlib.
import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=30, cumulative=[1]) plt.show()
Setting cumulative=True makes the histogram cumulative.
Complete the code to add labels and a title to the cumulative histogram.
import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=20, cumulative=True) plt.xlabel([1]) plt.ylabel('Frequency') plt.title('Cumulative Histogram') plt.show()
The x-axis label should describe the data values shown in the histogram.
Fix the error in the code to correctly plot a cumulative histogram with density normalization.
import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=25, cumulative=[1], density=True) plt.show()
To plot a cumulative histogram with density normalization, set cumulative=True.
Fill both blanks to create a cumulative histogram with 40 bins and a blue color.
import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=[1], cumulative=True, color=[2]) plt.show()
Use 40 bins and set color to 'blue' for the histogram.
Fill all three blanks to create a cumulative histogram with green color, 50 bins, and alpha transparency 0.5.
import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=[1], cumulative=True, color=[2], alpha=[3]) plt.show()
Set bins to 50, color to 'green', and alpha to 0.5 for transparency.
