@@ -6191,12 +6191,18 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6191
6191
Parameters
6192
6192
----------
6193
6193
C : array-like(M, N)
6194
- A 2D array or masked array. The values will be color-mapped.
6195
- This argument can only be passed positionally.
6194
+ The image data. Supported array shapes are:
6196
6195
6197
- C can in some cases be 3D with the last dimension as rgb(a).
6198
- This is available when C qualifies for image or pcolorimage type,
6199
- will throw a TypeError if C is 3D and quadmesh.
6196
+ - (M, N): an image with scalar data. The data is visualized
6197
+ using a colormap.
6198
+ - (M, N, 3): an image with RGB values (0-1 float or 0-255 int).
6199
+ - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),
6200
+ i.e. including transparency.
6201
+
6202
+ The first two dimensions (M, N) define the rows and columns of
6203
+ the image.
6204
+
6205
+ This parameter can only be passed positionally.
6200
6206
6201
6207
X, Y : tuple or array-like, default: ``(0, N)``, ``(0, M)``
6202
6208
*X* and *Y* are used to specify the coordinates of the
@@ -6221,9 +6227,9 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6221
6227
- Use 2D arrays *X*, *Y* if you need an *arbitrary quadrilateral
6222
6228
grid* (i.e. if the quadrilaterals are not rectangular).
6223
6229
6224
- In this case *X* and *Y* are 2D arrays with shape (M, N),
6230
+ In this case *X* and *Y* are 2D arrays with shape (M + 1 , N + 1 ),
6225
6231
specifying the x and y coordinates of the corners of the colored
6226
- quadrilaterals. See `~.Axes.pcolormesh` for details.
6232
+ quadrilaterals.
6227
6233
6228
6234
This is the most general, but the slowest to render. It may
6229
6235
produce faster and more compact output using ps, pdf, and
@@ -6292,10 +6298,6 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6292
6298
else :
6293
6299
style = "pcolorimage"
6294
6300
elif x .ndim == 2 and y .ndim == 2 :
6295
- if C .ndim > 2 :
6296
- raise ValueError (
6297
- 'pcolorfast needs to use quadmesh, '
6298
- 'which is not supported when x and y are 2D and C 3D' )
6299
6301
style = "quadmesh"
6300
6302
else :
6301
6303
raise TypeError ("arguments do not match valid signatures" )
@@ -6305,9 +6307,15 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6305
6307
if style == "quadmesh" :
6306
6308
# data point in each cell is value at lower left corner
6307
6309
coords = np .stack ([x , y ], axis = - 1 )
6310
+ if np .ndim (C ) == 2 :
6311
+ qm_kwargs = {"array" : np .ma .ravel (C )}
6312
+ elif np .ndim (C ) == 3 :
6313
+ qm_kwargs = {"color" : np .ma .reshape (C , (- 1 , C .shape [- 1 ]))}
6314
+ else :
6315
+ raise ValueError ("C must be 2D or 3D" )
6308
6316
collection = mcoll .QuadMesh (
6309
- nc , nr , coords ,
6310
- array = np . ma . ravel ( C ), alpha = alpha , cmap = cmap , norm = norm ,
6317
+ nc , nr , coords , ** qm_kwargs ,
6318
+ alpha = alpha , cmap = cmap , norm = norm ,
6311
6319
antialiased = False , edgecolors = "none" )
6312
6320
self .add_collection (collection , autolim = False )
6313
6321
xl , xr , yb , yt = x .min (), x .max (), y .min (), y .max ()
@@ -6331,7 +6339,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6331
6339
6332
6340
if vmin is not None or vmax is not None :
6333
6341
ret .set_clim (vmin , vmax )
6334
- else :
6342
+ elif np . ndim ( C ) == 2 : # C.ndim == 3 is RGB(A) so doesn't need scaling.
6335
6343
ret .autoscale_None ()
6336
6344
6337
6345
ret .sticky_edges .x [:] = [xl , xr ]
0 commit comments