matplotlib/matplotlib — Issue #708: set_clim not working with NonUniformImage
Author: rayosborn
Created: 2012-02-19 13:56:59+00:00
State: open

I reported on the mailing list that a call to im.set_clim to change the color scale on a NonUniformImage changes the colorbar but not the plot itself. It was pointed out that a further call to im.set_data fixes it, but it would be useful if that wasn't necessary.

Here is some test code. I set up an image plot as follows (using ipython --pylab=qt):

```
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.image import NonUniformImage

x=y=np.linspace(0,2*np.pi,101)
X,Y=np.meshgrid(x,y)
z=sin(X)*sin(Y)

ax=plt.gca()
extent = (x[0],x[-1],y[0],y[-1])
im = NonUniformImage(ax, extent=extent, origin=None)
im.set_data(x,y,z)

ax.images.append(im)
ax.set_xlim(x[0],x[-1])
ax.set_ylim(y[0],y[-1])

plt.colorbar(im)

plt.gcf().canvas.draw()
```

After that, I try to change the color scale using:

```
im.set_clim(0,0.5)
plt.gcf().canvas.draw()
```

The colorbar changes scale, but the plot is untouched. Is that the expected behavior?