Reputation: 1539
How would I go by if I wanted to plot a histogram when I already have the bins and their size ?
If I use :
plt.hist(x, bins)
it considers x as a list of results and not the already defined value of the corresponding bin.
Thanks
Upvotes: 0
Views: 388
Reputation: 23647
In that case you can simply create a bar chart with plt.bar
:
plt.bar(bins[:, 0], x, bins[:, 1] - bins[:, 0])
I simply assumed bins
is an array of shape (n, 2)
, where n
is 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.
Upvotes: 2