0

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)

Histogram

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.

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.