Hello All.
I just found a bug with the histogramme fonction of matplotlib.
It might been already known, in this case don't pay attention to my message.

The bug append with both OS: Windows XP and Linux (ubuntu). Both using the 
latest matplotlib release:  0.99.1

The bug is reproductible, with the folliwng script:

What the script shall do:
Let's say you are looking at the color of wagons on trains.
Every trains has 31 wagons.
Each time you see a red one, you write down it's number
At the end, you want to draw the histogramme with 
X axis: Number of the wagon in the tain
Y axis: Number of wagon of a specific number which is red.

My script
#------------------------------------------------------------------------------------------------------------------------------
import matplotlib.pyplot as plt

liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,1,2,2]
plt.figure(1)
plt.hist(sorted(liste_histo),bins=31)
plt.axis([0,31,0,20])
plt.show()
#-----------------------------------------------------------------------------------------------------------------------------

This script should give you a srange historamme, with bins that are half the 
size they shoud be.

With the same script, but a different countdown of my wagons, it works well:
#-----------------------------------------------------------------------------------------------------------------------------
import matplotlib.pyplot as plt

liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,15,25]
plt.figure(1)
plt.hist(sorted(liste_histo),bins=31)
plt.axis([0,31,0,20])
plt.show()
#-----------------------------------------------------------------------------------------------------------------------------

I corrected this error by adding a 32 (my max value on the histogramme should 
be a 31).
asking 32 bins, and drawing the histogramme between 1 and 31:

#------------------------------------------------------------------------------------------------------------------------------

import matplotlib.pyplot as plt



liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,1,2,2,32]

plt.figure(1)

plt.hist(sorted(liste_histo),bins=32)

plt.axis([0,31,0,20])

plt.show()

#-----------------------------------------------------------------------------------------------------------------------------

And it works...
Am I the only one to get a probleme here?

Thanks for reading me

Julien




      
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to