Anthony Lethuillier February 2016
Python histogram with pre-set size of bins
How would I go by if I wanted to plot a histogram when I already have the bins and their size ?
If I use :
it considers x as a list of results and not the already defined value of the corresponding bin.
kazemakase February 2016
In that case you can simply create a bar chart with
plt.bar(bins[:, 0], x, bins[:, 1] - bins[:, 0])
I simply assumed
bins is an array of shape
(n, 2), where
nis the number of bins. The first column is the lowest value covered by the bin and the second column is the upper value covered by the bin.
Asked in February 2016
Viewed 3,662 times
Answered 1 times
Leave an answer
Quote of the day: live life