From: Alexandar H. <vio...@gm...> - 2009-06-17 22:32:37
|
Hello, I've been having fun using hexbin, but I'd like to have consistent bin sizes and plot ranges for different sets of data. What I'm finding is that the bin sizes are primarily determined by the input data mins and maxes. For instance, I'm plotting data with something like: # import matplotlib.pyplot as plt # plt.hexbin(x,y, cmap=cm.hot, gridsize=(50,50)) # plt.axis([xmin, xmax, ymin, ymax]) # plt.title("2D Histogram") # cb = plt.colorbar() # cb.set_label('counts') # plt.show() where xmin, etc are a fixed range. If my data sets span sizeably different ranges, then the hexagon sizes come out completely different. I'd like to avoid increasing the gridsize in one or both dimensions too much as that would require very large grids in some instances. I thought my solution to the problems would be to use the extent function in hexbin but when I try, for instance: # plt.hexbin(x,y, cmap=cm.hot, gridsize=(50,50), extent=[xmin,xmax,ymin,ymax]) I get these strange errors: File "HexPlotLog.py", line 64, in <module> plt.hexbin(x,y, cmap=cm.hot, gridsize=(50,50), extent=[xmin, xmax, ymin, ymax]) File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line 1920, in hexbin ret = gca().hexbin(*args, **kwargs) File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line 5447, in hexbin collection.update(kwargs) File "/usr/lib64/python2.5/site-packages/matplotlib/artist.py", line 548, in update raise AttributeError('Unknown property %s'%k) AttributeError: Unknown property extent The other thing I'd like to do is to set the background color of the plot to black, or otherwise the same color as a bin of zero. I imagine this is something I can find in the manuals, but since I'm asking questions, may as well include it :) I appreciate any help that can be offered. Best, Alex |