Reputation: 135
first time using python I already plotted histogram using option 'bins'
plt.hist(data['salary'], bins = 10)
bins divide the total interval linearly. that means, if salary in [0,1000[ then we got 10 intervals [0,100[, [100,200[ ... [900,1000[ in case using bins = 10. But what if I want to divide [0,1000[ into only 3 intervals [0,500[, [500,900[ and [900,1000[ Any solution ??
Upvotes: 0
Views: 517
Reputation: 59549
From the matplotlib
docs
bins : int or sequence or str, optional
If an integer is given, bins + 1 bin edges are calculated and returned, consistent with numpy.histogram.
If bins is a sequence, gives bin edges, including left edge of first bin and right edge of last bin. In this case, bins is returned unmodified.
Specify: bins=[0, 500, 900, 1000]
, which will give you the bins: [0, 100), [500, 900), [900, 1000]. Notice all bins but the last are half-open.
Upvotes: 2