Kenenbek Arzymatov
Kenenbek Arzymatov

Reputation: 9109

How to change number of bins in matplotlib?

I have the following code:

ax1.hist(true_time, bins=500, edgecolor="none")
ax2.hist(true_time_2, bins=500, edgecolor="none")

I expected that it would give me two hists with the same number of bins, but it wouldn't: enter image description here

How to do it correctly?

Upvotes: 2

Views: 4075

Answers (2)

Helen
Helen

Reputation: 367

The reason that you get different binning is that your two datasets are different. As a comment said, in the second plot you do have 500 bins.

My guess is that true_time has very sparsely distributed data.

Upvotes: 0

unddoch
unddoch

Reputation: 6004

If you have some distant outlier in true_time, it may be that the bins were made just really really big to include it.

Upvotes: 0

Related Questions