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: http://old.nabble.com/file/p30998708/1dhist_color.png http://old.nabble.com/file/p30998708/2dhist_zeroed_colorbar.png -- 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. ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users