On Wednesday 15 August 2007 05:05:51 pm you wrote: > Darren Dale wrote: > > I'm doing something along the lines of: > > > > create an initial image with imshow > > add a colorbar > > update the image using the image's set_data method > > > > Occassionally, the extents of the image will change. How do I handle > > that? The only place I can find to set the extents is in the call to > > imshow. The resulting image has a get_extents, but not a setter. I can't > > make repeated calls to imshow, because the new image isnt coupled to the > > colorbar. I can't figure out how to couple the colorbar to the new image, > > and I dont know how to get rid of the old colorbar to clear space for a > > new one. > > Darren, > > Try directly setting the extent via the _extent attribute of the image > object. If that works and doesn't cause any new problems, then we can > add a trivial set_extent method.
I just committed this patch in svn. The additional code was lifted from imshow, to reshape the axes along with the image. Darren Index: lib/matplotlib/image.py =================================================================== --- lib/matplotlib/image.py (revision 3709) +++ lib/matplotlib/image.py (working copy) @@ -236,6 +236,18 @@ # by mistake. self.set_data(A) + + def set_extent(self, extent): + """extent is data axes (left, right, bottom, top) for making image plots + """ + self._extent = extent + + xmin, xmax, ymin, ymax = extent + corners = (xmin, ymin), (xmax, ymax) + self.axes.update_datalim(corners) + if self.axes._autoscaleon: + self.axes.set_xlim((xmin, xmax)) + self.axes.set_ylim((ymin, ymax)) def get_interpolation(self): """ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel