I am trying to use imshow() with a dinamically changing set of matrices. What my application does, is just to respond to a user selection from a wxPython radiobutton and, based on the user’s choice, display a different matrix on a matplotlib figure (I am using the OO interface). I also have an horizontal colorbar to let the user orient himself over the matrix values. Well, these matrices have different magnitues in value, and I was expecting that the colorbar would be updated with the new image data. Isn’t the colorbar supposed to update when the input image/pcolor/whatever changes?
This is what I have at the moment:
self.palette = matplotlib.cm.jet
minp = min(property)
maxp = max(property)
here do the property reshape to get a matrix…
imshow the matrix
if not hasattr(self, “image”):
self.image = self.leftaxis.imshow(property, cmap=self.palette,
norm=colors.normalize(vmin=minp, vmax=maxp, clip=False))
self.image.set_norm(norm=colors.normalize(vmin=minp, vmax=maxp, clip=False))
if it doesn’t exist, create a colorbar
if not hasattr(self, “colorbar”):
self.colorbar = self.fig.colorbar(self.image, cax=self.cax, orientation=“horizontal”)
It doesn’t work… I mean, the colorbar axis limits are updated, but not the colorbar colors. Let’s suppose that the first matrix has a min(property)=1000 and max(property)=10000, I get that values around 1000 are red/maroon. When I select the second matrix, with min(property)=1 and max(property)=10, everything in the colorbar is red/maroon…
Is there a solution for this kind of problem? Am I missing something?
Thank you very much for your suggestions.
“Imagination Is The Only Weapon In The War Against Reality.”