On Wed, 2007-04-04 at 16:26 +0200, David Fokkema wrote:
> Hi group,
> 
> I have the following ipython 'session':
> 
> In [23]: data = [0, 0.4, 0.6, 1, 2, 3]
> 
> In [24]: bins = [0, 1, 2, 3]
> 
> In [25]: hist(data, bins, align='edge')
> Out[25]: (array([3, 1, 1, 1]), [0, 1, 2, 3], <a list of 4 Patch
> objects>)
> 
> In [26]: hist(data, bins, align='center')
> Out[26]: (array([3, 1, 1, 1]), [0, 1, 2, 3], <a list of 4 Patch
> objects>)
> 
> 
> I would suspect that the histogram output from 'center' should be [2, 2,
> 1, 1]. Why is this not so? At least, the two should be different? I
> would say that with edge, my bins would be 0-1, 1-2, 2-3, 3-4, and that
> center should give me -0.5-0.5, 0.5-1.5, 1.5-2.5, 2.5-3.5, but this
> seems not to be the case??? Any help understanding this would be greatly
> appreciated!

It seems that the hist function simply calls matplotlib.mlab.hist
without any regard to the bins (be they edge or centered values) and
passes the plotting through to the 'bar' function. This function places
the bar with either the edge at the bin value or the center at the bin
value. If I choose center, the result is that my histogram is calculated
for edge values but the bars are placed at center values which is
completely misleading and wrong! I'd say this is a bug, but I may be
overlooking something here...

Thanks,

David


> 
> Thanks,
> 
> David
> 
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to