@@ -106,7 +106,8 @@ def changed(self):
106106 self ._imcache = None
107107 cm .ScalarMappable .changed (self )
108108
109- def make_image (self , flipy ):
109+ def make_image (self , flipy ):
110+ self ._imcache = None
110111 if self ._A is not None :
111112 if self ._imcache is None :
112113 x = self .to_rgba (self ._A , self ._alpha )
@@ -158,10 +159,12 @@ def make_image(self, flipy):
158159 rx = widthDisplay / numcols
159160 ry = heightDisplay / numrows
160161
162+
161163 if im .get_aspect ()== _image .ASPECT_PRESERVE :
162164 if ry < rx : rx = ry
163165 # todo: center the image in viewport
164166 im .apply_scaling (rx , rx )
167+
165168 else :
166169 im .apply_scaling (rx , ry )
167170
@@ -258,21 +261,22 @@ def set_interpolation(self, s):
258261 if not self ._interpd .has_key (s ):
259262 raise ValueError ('Illegal interpolation string' )
260263 self ._interpolation = s
261-
262-
263-
264-
265264
266265 def get_extent (self ):
267266 'get the image extent: xmin, xmax, ymin, ymax'
268267 if self ._extent is not None :
269268 return self ._extent
270- else :
269+ else :
271270 numrows , numcols = self .get_size ()
272- width , height = numcols , numrows
273- return 0 , width , 0 , height
274-
275-
271+ iwidth , iheight = numcols , numrows
272+ #return 0, width, 0, height
273+ tmp , tmp , dwidth , dheight = self .axes .bbox .get_bounds ()
274+ sx = dwidth / iwidth
275+ sy = dheight / iheight
276+
277+ if self .get_aspect ()== 'preserve' and sy < sx : sx = sy
278+ return 0 , 1.0 / sx * dwidth , 0 , 1.0 / sy * dheight
279+
276280class FigureImage (Artist , cm .ScalarMappable ):
277281 def __init__ (self , fig ,
278282 cmap = None ,
0 commit comments