@@ -6254,7 +6254,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6254
6254
"'norm' must be an instance of 'mcolors.Normalize'" )
6255
6255
6256
6256
C = args [- 1 ]
6257
- nr , nc = C .shape
6257
+ nr , nc = np .shape ( C )
6258
6258
if len (args ) == 1 :
6259
6259
style = "image"
6260
6260
x = [0 , nc ]
@@ -6282,54 +6282,29 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6282
6282
raise TypeError ("need 1 argument or 3 arguments" )
6283
6283
6284
6284
if style == "quadmesh" :
6285
-
6286
- # convert to one dimensional arrays
6287
- # This should also be moved to the QuadMesh class
6288
-
6289
6285
# data point in each cell is value at lower left corner
6290
- C = ma .ravel (C )
6291
- X = x .ravel ()
6292
- Y = y .ravel ()
6293
- Nx = nc + 1
6294
- Ny = nr + 1
6295
-
6296
- # The following needs to be cleaned up; the renderer
6297
- # requires separate contiguous arrays for X and Y,
6298
- # but the QuadMesh class requires the 2D array.
6299
- coords = np .empty (((Nx * Ny ), 2 ), np .float64 )
6300
- coords [:, 0 ] = X
6301
- coords [:, 1 ] = Y
6302
-
6303
- # The QuadMesh class can also be changed to
6304
- # handle relevant superclass kwargs; the initializer
6305
- # should do much more than it does now.
6306
- collection = mcoll .QuadMesh (nc , nr , coords , 0 , edgecolors = "None" )
6307
- collection .set_alpha (alpha )
6308
- collection .set_array (C )
6309
- collection .set_cmap (cmap )
6310
- collection .set_norm (norm )
6286
+ coords = np .stack ([x , y ], axis = - 1 )
6287
+ collection = mcoll .QuadMesh (
6288
+ nc , nr , coords ,
6289
+ array = np .ma .ravel (C ), alpha = alpha , cmap = cmap , norm = norm ,
6290
+ antialiased = False , edgecolors = "none" )
6311
6291
self .add_collection (collection , autolim = False )
6312
- xl , xr , yb , yt = X .min (), X .max (), Y .min (), Y .max ()
6292
+ xl , xr , yb , yt = x .min (), x .max (), y .min (), y .max ()
6313
6293
ret = collection
6314
6294
6315
6295
else : # It's one of the two image styles.
6316
- xl , xr , yb , yt = x [0 ], x [- 1 ], y [0 ], y [- 1 ]
6317
-
6296
+ extent = xl , xr , yb , yt = x [0 ], x [- 1 ], y [0 ], y [- 1 ]
6318
6297
if style == "image" :
6319
- im = mimage .AxesImage (self , cmap , norm ,
6320
- interpolation = 'nearest' ,
6321
- origin = 'lower' ,
6322
- extent = (xl , xr , yb , yt ),
6323
- ** kwargs )
6324
- im .set_data (C )
6325
- im .set_alpha (alpha )
6298
+ im = mimage .AxesImage (
6299
+ self , cmap , norm ,
6300
+ data = C , alpha = alpha , extent = extent ,
6301
+ interpolation = 'nearest' , origin = 'lower' ,
6302
+ ** kwargs )
6326
6303
elif style == "pcolorimage" :
6327
- im = mimage .PcolorImage (self , x , y , C ,
6328
- cmap = cmap ,
6329
- norm = norm ,
6330
- alpha = alpha ,
6331
- ** kwargs )
6332
- im .set_extent ((xl , xr , yb , yt ))
6304
+ im = mimage .PcolorImage (
6305
+ self , x , y , C ,
6306
+ cmap = cmap , norm = norm , alpha = alpha , extent = extent ,
6307
+ ** kwargs )
6333
6308
self .add_image (im )
6334
6309
ret = im
6335
6310
0 commit comments