matplotlib - Python pyplot.hist ignores range if it is larger than dataset? -
i making histograms variety of datasets , want them use same bins comparable. seems if bin distribution large dataset, however, hist ignores range , makes smaller one. example:
x=[random.randrange(1,10) _ in xrange(1000)] plt.hist(x, 50, range=[0, 100]) plt.show()
i 5 bins 0-10 instead of 50 0-100. assume missing obvious else parameter?
thanks!
in [37]: plt.hist(x, 50, range=[0,100]) out[37]: (array([ 103., 228., 233., 228., 208., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]), array([ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18., 20., 22., 24., 26., 28., 30., 32., 34., 36., 38., 40., 42., 44., 46., 48., 50., 52., 54., 56., 58., 60., 62., 64., 66., 68., 70., 72., 74., 76., 78., 80., 82., 84., 86., 88., 90., 92., 94., 96., 98., 100.]), <a list of 50 patch objects>)
the function returns bins , patches. can see here, there in fact 50 bins there. matplotlib chooses clip figure off there no more data.
Comments
Post a Comment