@@ -997,10 +997,26 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
997
997
height = (round (t ) + 0.5 ) - (round (b ) - 0.5 )
998
998
width *= magnification
999
999
height *= magnification
1000
- im = _image .pcolor (self ._Ax , self ._Ay , A ,
1001
- int (height ), int (width ),
1002
- (x0 , x0 + v_width , y0 , y0 + v_height ),
1003
- _interpd_ [self ._interpolation ])
1000
+ x_pix = np .linspace (x0 , x0 + v_width , int (width ))
1001
+ y_pix = np .linspace (y0 , y0 + v_height , int (height ))
1002
+ if self ._interpolation == "nearest" :
1003
+ x_mid = (self ._Ax [:- 1 ] + self ._Ax [1 :]) / 2
1004
+ y_mid = (self ._Ay [:- 1 ] + self ._Ay [1 :]) / 2
1005
+ x_int = x_mid .searchsorted (x_pix )
1006
+ y_int = y_mid .searchsorted (y_pix )
1007
+ im = A [y_int [:, None ], x_int [None , :]]
1008
+ else : # self._interpolation == "bilinear"
1009
+ x_int = np .maximum (self ._Ax .searchsorted (x_pix ), 1 ) - 1
1010
+ x_frac = (x_pix - self ._Ax [x_int ]) / np .diff (self ._Ax )[x_int ]
1011
+ y_int = np .maximum (self ._Ax .searchsorted (y_pix ), 1 ) - 1
1012
+ y_frac = (y_pix - self ._Ay [y_int ]) / np .diff (self ._Ay )[y_int ]
1013
+ x_int , y_int = np .meshgrid (x_int , y_int , indexing = "xy" )
1014
+ x_frac = x_frac [None , :, None ]
1015
+ y_frac = y_frac [:, None , None ]
1016
+ im = ((1 - y_frac ) * (1 - x_frac ) * A [y_int , x_int ]
1017
+ + y_frac * (1 - x_frac ) * A [y_int + 1 , x_int ]
1018
+ + (1 - y_frac ) * x_frac * A [y_int , x_int + 1 ]
1019
+ + y_frac * x_frac * A [y_int + 1 , x_int + 1 ])
1004
1020
return im , l , b , IdentityTransform ()
1005
1021
1006
1022
def set_data (self , x , y , A ):
@@ -1123,11 +1139,15 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
1123
1139
else :
1124
1140
A = self ._rgbacache
1125
1141
vl = self .axes .viewLim
1126
- im = _image .pcolor2 (self ._Ax , self ._Ay , A ,
1127
- height ,
1128
- width ,
1129
- (vl .x0 , vl .x1 , vl .y0 , vl .y1 ),
1130
- bg )
1142
+
1143
+ x_pix = np .linspace (vl .x0 , vl .x1 , int (width ))
1144
+ y_pix = np .linspace (vl .y0 , vl .y1 , int (height ))
1145
+ x_int = np .clip (self ._Ax .searchsorted (x_pix ) - 1 , 0 , len (self ._Ax ) - 2 )
1146
+ y_int = np .clip (self ._Ay .searchsorted (y_pix ) - 1 , 0 , len (self ._Ay ) - 2 )
1147
+ im = A [y_int [:, None ], x_int [None , :]]
1148
+ x_out = (x_pix < self ._Ax [0 ]) | (x_pix > self ._Ax [- 1 ])
1149
+ y_out = (y_pix < self ._Ay [0 ]) | (y_pix > self ._Ay [- 1 ])
1150
+ im [y_out [:, None ] | x_out [None , :]] = bg
1131
1151
return im , l , b , IdentityTransform ()
1132
1152
1133
1153
def _check_unsampled_image (self , renderer ):
0 commit comments