error in hexbin normalization

Mike Bauer wrote:

Eric,

Thanks for the reply. I'm trying to show the relative 2d distribuion between 2 sets of data. I thought the normalization would ease the comparison. Fixing the ' doesn't help.

So are you saying I need an instance of something.normalize rather than just passing norm='normalize'?

It sounds like you are misunderstanding the norm kwarg; it is for controlling the mapping of an arbitrary range of numbers to the 0-1 range that is used in color mapping. The default is a linear mapping; one can use a log mapping instead ("norm=colors.LogNorm()"), or make your own mapping function, etc. The norm kwarg takes an instance of a Normalize class or subclass. See colors.py to find out what Normalize subclasses are available. But, you may not need to specify one at all, depending on what it is you are trying to do.

I still don't understand what it is that you wanted to "normalize". What was the undesirable characteristic of the plot you had before you put in the norm kwarg?

Eric

ยทยทยท

Mike

Sent from my iPhone

On Mar 20, 2009, at 5:15 PM, Eric Firing <efiring@...202...> wrote:

Mike Bauer wrote:

Hello,
Quick note. I'm making plots with hexbin and everything works correctly until I try to use the norm='Normalize' option at which point I get:
Traceback (most recent call last):
  File "diff_engine_v2tmp.py", line 731, in <module>
    kept_and_discards)
  File "diff_engine_v2tmp.py", line 605, in main
    plt.hexbin(xdat,ydat,cmap=cm.jet,gridsize=25,norm=Normalize' )

What is that single quote mark doing after Normalize? If we ignore it, then it looks like you are passing a class, not a class instance as the kwarg needs.

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/matplotlib/pyplot.py", line 1920, in hexbin
    ret = gca().hexbin(*args, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/matplotlib/axes.py", line 5452, in hexbin
    collection.autoscale_None()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/matplotlib/cm.py", line 148, in autoscale_None
    self.norm.autoscale_None(self._A)
AttributeError: 'int' object has no attribute 'autoscale_None'

This part of the traceback is also a little puzzling; I'm not sure why self.norm is an int at this point.

I assume this a bug of some sort.

No, I think the problem is that you are passing a class instead of an instance of a class as the norm kwarg to hexbin. (It is not completely clear to me from the traceback, however--there is that strange single quote mark.) What kind of normalization are you trying to to? In other words, what are you trying to accomplish by specifying the norm kwarg?

Eric

Thanks for any ideas.
Mike
Using:
   os-x 10.5.6
   python 2.5.4 from macports
   matplotlib 0.98.5.2 from macports
------------------------------------------------------------------------------

Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options