@@ -205,7 +205,9 @@ def make_image(self, magnification=1.0):
205205 tx = (xmin - self .axes .viewLim .x0 )/ dxintv * numcols
206206 ty = (ymin - self .axes .viewLim .y0 )/ dyintv * numrows
207207
208- l , b , widthDisplay , heightDisplay = self .axes .bbox .bounds
208+ l , b , r , t = self .axes .bbox .extents
209+ widthDisplay = (round (r ) + 0.5 ) - (round (l ) - 0.5 )
210+ heightDisplay = (round (t ) + 0.5 ) - (round (b ) - 0.5 )
209211 widthDisplay *= magnification
210212 heightDisplay *= magnification
211213 im .apply_translation (tx , ty )
@@ -226,7 +228,7 @@ def draw(self, renderer, *args, **kwargs):
226228 warnings .warn ("Images are not supported on non-linear axes." )
227229 im = self .make_image (renderer .get_image_magnification ())
228230 l , b , widthDisplay , heightDisplay = self .axes .bbox .bounds
229- renderer .draw_image (l , b , im , self .axes .bbox .frozen (),
231+ renderer .draw_image (round ( l ), round ( b ) , im , self .axes .bbox .frozen (),
230232 * self .get_transformed_clip_path_and_affine ())
231233
232234 def contains (self , mouseevent ):
@@ -378,7 +380,9 @@ def make_image(self, magnification=1.0):
378380 raise RuntimeError ('You must first set the image array' )
379381
380382 x0 , y0 , v_width , v_height = self .axes .viewLim .bounds
381- l , b , width , height = self .axes .bbox .bounds
383+ l , b , r , t = self .axes .bbox .extents
384+ width = (round (r ) + 0.5 ) - (round (l ) - 0.5 )
385+ height = (round (t ) + 0.5 ) - (round (b ) - 0.5 )
382386 width *= magnification
383387 height *= magnification
384388 im = _image .pcolor (self ._Ax , self ._Ay , self ._A ,
@@ -487,8 +491,11 @@ def make_image(self, magnification=1.0):
487491 fc = self .axes .get_frame ().get_facecolor ()
488492 bg = mcolors .colorConverter .to_rgba (fc , 0 )
489493 bg = (np .array (bg )* 255 ).astype (np .uint8 )
490- width = self .axes .bbox .width * magnification
491- height = self .axes .bbox .height * magnification
494+ l , b , r , t = self .axes .bbox .extents
495+ width = (round (r ) + 0.5 ) - (round (l ) - 0.5 )
496+ height = (round (t ) + 0.5 ) - (round (b ) - 0.5 )
497+ width = width * magnification
498+ height = height * magnification
492499 if self .check_update ('array' ):
493500 A = self .to_rgba (self ._A , alpha = self ._alpha , bytes = True )
494501 self ._rgbacache = A
@@ -508,8 +515,8 @@ def make_image(self, magnification=1.0):
508515 def draw (self , renderer , * args , ** kwargs ):
509516 if not self .get_visible (): return
510517 im = self .make_image (renderer .get_image_magnification ())
511- renderer .draw_image (self .axes .bbox .xmin ,
512- self .axes .bbox .ymin ,
518+ renderer .draw_image (round ( self .axes .bbox .xmin ) ,
519+ round ( self .axes .bbox .ymin ) ,
513520 im ,
514521 self .axes .bbox .frozen (),
515522 * self .get_transformed_clip_path_and_affine ())
@@ -638,7 +645,7 @@ def make_image(self, magnification=1.0):
638645 def draw (self , renderer , * args , ** kwargs ):
639646 if not self .get_visible (): return
640647 im = self .make_image ()
641- renderer .draw_image (self .ox , self .oy , im , self .figure .bbox ,
648+ renderer .draw_image (round ( self .ox ), round ( self .oy ) , im , self .figure .bbox ,
642649 * self .get_transformed_clip_path_and_affine ())
643650
644651 def write_png (self , fname ):
0 commit comments