Skip to content

set_clim not working with NonUniformImage #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rayosborn opened this issue Feb 19, 2012 · 2 comments · Fixed by #710
Closed

set_clim not working with NonUniformImage #708

rayosborn opened this issue Feb 19, 2012 · 2 comments · Fixed by #710

Comments

@rayosborn
Copy link

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=np.sin(X)*np.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?

@efiring
Copy link
Member

efiring commented Feb 19, 2012

This is actually a result not of a bug in the ordinary sense, but of NonUniformImage being only half-baked. It has never been incorporated as an Axes method (not to mention pyplot), and it has not been updated to support caching or any colormap changes. I think it makes sense to do this whole update, which should not be very difficult, in the master branch.

@efiring
Copy link
Member

efiring commented Aug 13, 2012

#710 took care of the problem noted here.

@efiring efiring closed this as completed Aug 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants