Reputation: 518
I am trying to plot a simple histogram with matplotlib with the following code:
n, bins, patches = plt.hist(theta_deg[:,:], bins=36, rwidth=1, facecolor='green', alpha=0.75)
The parameter rwidth deletes the white spaces on each side of the bars. theta_deg is a (1025,70) matrix. The result is a histogram with a much higher number of bins than the 36 I want to get, as shown in the image. I would like to have all the 1025*70 points within 36 bars only. Many thanks for any help.
Upvotes: 0
Views: 588
Reputation: 339112
You're plotting several histograms, one for each column of the array and each with 36 bins. Those are stiched together and due to the same color being used appear as one single histogram.
Remove rwidth
and flatten your array:
n, bins, patches = plt.hist(theta_deg.flatten(), bins=36, facecolor='green', alpha=0.75)
Upvotes: 2