Bug in pcolor's use of vmax, vmin?

pcolor doesn't seem to be using the vmin and vmax values that I supply
to it. If I do:

X,Y = meshgrid(arange(-2,2,.1), arange(-2,2,.1))
pcolor(X**2 + Y**2, vmin = 1., vmax=2.)

I see a smooth paraboloid (ie, without the min/max clipping in the
center on the edge that I would expect).

However, if I instead do:

imshow(X**2 + Y**2, vmin = 1., vmax=2.)

I see what I expect, a circular dark region, surrounded by a smoothly
varying ring, surrounded by a white area to the edge of the plot.

I'm using OS X 10.4.5, Python 2.3.5, and matplotlib 0.87. Am I doing
something wrong?

Thanks,
Greg

Greg,

Gregory Novak wrote:

pcolor doesn't seem to be using the vmin and vmax values that I supply
to it. If I do:

X,Y = meshgrid(arange(-2,2,.1), arange(-2,2,.1))
pcolor(X**2 + Y**2, vmin = 1., vmax=2.)

I see a smooth paraboloid (ie, without the min/max clipping in the
center on the edge that I would expect).

However, if I instead do:

imshow(X**2 + Y**2, vmin = 1., vmax=2.)

I see what I expect, a circular dark region, surrounded by a smoothly
varying ring, surrounded by a white area to the edge of the plot.

I'm using OS X 10.4.5, Python 2.3.5, and matplotlib 0.87. Am I doing
something wrong?

No, you found a bug. I have fixed it, but it may take me a little while to get it committed to svn--this will be my first commit since the switch from cvs to svn.

I will send another message shortly.

Eric

Greg,

Gregory Novak wrote:

pcolor doesn't seem to be using the vmin and vmax values that I supply
to it.

It is fixed in svn now. The relevant part is:

--- lib/matplotlib/axes.py (revision 2126)
+++ lib/matplotlib/axes.py (working copy)
@@ -2312,10 +2312,8 @@
          if cmap is not None: assert(isinstance(cmap, Colormap))
          collection.set_cmap(cmap)
          collection.set_norm(norm)
+ collection.set_clim(vmin, vmax)

- if norm is not None:
- collection.set_clim(vmin, vmax)

ยทยทยท

-
          self.grid(False)

          x = X.compressed()

We don't want to check for norm being None, because after calling collection.set_norm, the collection's norm is *not* None, so it is always OK (and necessary, if we have provided values for vmin and vmax) to call set_clim.

Eric