Skip to content Skip to sidebar Skip to footer

Spacing Between Bars In Matplotlib Hist() With Thousands Of Bins

I'm making histograms using matplotlib's hist() function or bar(), and I want to use >10,000 bins (one bin to represent the counts at each coordinate of a large entity). Is ther

Solution 1:

The parameter rwidth specifies the width of your bar relative to the width of your bin. For example, if your bin width is say 1 and rwidth=0.5, the bar width will be 0.5. On both side of the bar you will have a space of 0.25.

Mind: this gives a space of 0.5 between consecutive bars. With the number of bins you have, you won't see these spaces. But with fewer bins they do show up.

enter image description here

Post a Comment for "Spacing Between Bars In Matplotlib Hist() With Thousands Of Bins"