1D and 2D histograms using numpy and matplotlib

There have been a lot of messages lately about histograms in general and I
though it was about time I share a bit of code I am using to handle them. I
have created a Histogram class that inherits directly from the numpy.ndarray
object. I then have a plothist() method which creates the plot on a canvas.
For 1D histograms, I create the PathPatch (Polygon) fom a series of points.
This is so that the histogram can be a single patch with a facecolor and an
edgecolor, though I usually have the edgecolor set to None. For 2D
histograms I use imshow() with interpolation='nearest'. This gives
rectangular bins which I prefer (over the hexbin) since typically, the
resolution of the x and y axes are different for me. I'm relatively new to
python so the code may be improved, but so far, it has worked quite nicely
for me. Hopefully it will work for someone else! And of course, if anyone
has any comments or suggestions, please let me know!

All definitions are in histogram.py. Put the test.py file in the same
directory and run test.py to make sure everything works.

http://old.nabble.com/file/p30998708/histogram.py histogram.py
http://old.nabble.com/file/p30998708/test.py test.py

Running test.py should give you several histogram figures including these:



View this message in context: http://old.nabble.com/1D-and-2D-histograms-using-numpy-and-matplotlib-tp30998708p30998708.html
Sent from the matplotlib - users mailing list archive at Nabble.com.