I am trying to get a histogram with already binned data. I have been trying to use bar()
for this, but I can't seem to figure out how to make it a stepped histogram like this one from the examples, instead of a filled histogram.
To normalize a histogram in Python, we can use hist() method. In normalized bar, the area underneath the plot should be 1.
The towers or bars of a histogram are called bins. The height of each bin shows how many values from that data fall into that range. Width of each bin is = (max value of data – min value of data) / total number of bins. The default value of the number of bins to be created in a histogram is 10.
You could cheat, by offsetting your data and using plot
instead:
from matplotlib import pyplot
import numpy as np
#sample data:
x = np.arange(30)
y = np.cumsum(np.arange(30))
#offset the x for horizontal, repeat the y for vertical:
x = np.ravel(zip(x,x+1))
y = np.ravel(zip(y,y))
pyplot.plot(x,y)
pyplot.savefig('plt.png')
the plot:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With