@@ -6213,7 +6213,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6213
6213
"'norm' must be an instance of 'mcolors.Normalize'" )
6214
6214
6215
6215
C = args [- 1 ]
6216
- nr , nc = C .shape
6216
+ nr , nc = np .shape ( C )
6217
6217
if len (args ) == 1 :
6218
6218
style = "image"
6219
6219
x = [0 , nc ]
@@ -6241,54 +6241,29 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6241
6241
raise TypeError ("need 1 argument or 3 arguments" )
6242
6242
6243
6243
if style == "quadmesh" :
6244
-
6245
- # convert to one dimensional arrays
6246
- # This should also be moved to the QuadMesh class
6247
-
6248
6244
# data point in each cell is value at lower left corner
6249
- C = ma .ravel (C )
6250
- X = x .ravel ()
6251
- Y = y .ravel ()
6252
- Nx = nc + 1
6253
- Ny = nr + 1
6254
-
6255
- # The following needs to be cleaned up; the renderer
6256
- # requires separate contiguous arrays for X and Y,
6257
- # but the QuadMesh class requires the 2D array.
6258
- coords = np .empty (((Nx * Ny ), 2 ), np .float64 )
6259
- coords [:, 0 ] = X
6260
- coords [:, 1 ] = Y
6261
-
6262
- # The QuadMesh class can also be changed to
6263
- # handle relevant superclass kwargs; the initializer
6264
- # should do much more than it does now.
6265
- collection = mcoll .QuadMesh (nc , nr , coords , 0 , edgecolors = "None" )
6266
- collection .set_alpha (alpha )
6267
- collection .set_array (C )
6268
- collection .set_cmap (cmap )
6269
- collection .set_norm (norm )
6245
+ coords = np .stack ([x , y ], axis = - 1 )
6246
+ collection = mcoll .QuadMesh (
6247
+ nc , nr , coords ,
6248
+ array = np .ma .ravel (C ), alpha = alpha , cmap = cmap , norm = norm ,
6249
+ antialiased = False , edgecolors = "none" )
6270
6250
self .add_collection (collection , autolim = False )
6271
- xl , xr , yb , yt = X .min (), X .max (), Y .min (), Y .max ()
6251
+ xl , xr , yb , yt = x .min (), x .max (), y .min (), y .max ()
6272
6252
ret = collection
6273
6253
6274
6254
else : # It's one of the two image styles.
6275
- xl , xr , yb , yt = x [0 ], x [- 1 ], y [0 ], y [- 1 ]
6276
-
6255
+ extent = xl , xr , yb , yt = x [0 ], x [- 1 ], y [0 ], y [- 1 ]
6277
6256
if style == "image" :
6278
- im = mimage .AxesImage (self , cmap , norm ,
6279
- interpolation = 'nearest' ,
6280
- origin = 'lower' ,
6281
- extent = (xl , xr , yb , yt ),
6282
- ** kwargs )
6283
- im .set_data (C )
6284
- im .set_alpha (alpha )
6257
+ im = mimage .AxesImage (
6258
+ self , cmap , norm ,
6259
+ data = C , alpha = alpha , extent = extent ,
6260
+ interpolation = 'nearest' , origin = 'lower' ,
6261
+ ** kwargs )
6285
6262
elif style == "pcolorimage" :
6286
- im = mimage .PcolorImage (self , x , y , C ,
6287
- cmap = cmap ,
6288
- norm = norm ,
6289
- alpha = alpha ,
6290
- ** kwargs )
6291
- im .set_extent ((xl , xr , yb , yt ))
6263
+ im = mimage .PcolorImage (
6264
+ self , x , y , C ,
6265
+ cmap = cmap , norm = norm , alpha = alpha , extent = extent ,
6266
+ ** kwargs )
6292
6267
self .add_image (im )
6293
6268
ret = im
6294
6269
0 commit comments