@@ -6191,12 +6191,18 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
61916191 Parameters
61926192 ----------
61936193 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:
61966195
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.
62006206
62016207 X, Y : tuple or array-like, default: ``(0, N)``, ``(0, M)``
62026208 *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,
62216227 - Use 2D arrays *X*, *Y* if you need an *arbitrary quadrilateral
62226228 grid* (i.e. if the quadrilaterals are not rectangular).
62236229
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 ),
62256231 specifying the x and y coordinates of the corners of the colored
6226- quadrilaterals. See `~.Axes.pcolormesh` for details.
6232+ quadrilaterals.
62276233
62286234 This is the most general, but the slowest to render. It may
62296235 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,
62926298 else :
62936299 style = "pcolorimage"
62946300 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' )
62996301 style = "quadmesh"
63006302 else :
63016303 raise TypeError ("arguments do not match valid signatures" )
@@ -6305,9 +6307,15 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
63056307 if style == "quadmesh" :
63066308 # data point in each cell is value at lower left corner
63076309 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" )
63086316 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 ,
63116319 antialiased = False , edgecolors = "none" )
63126320 self .add_collection (collection , autolim = False )
63136321 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,
63316339
63326340 if vmin is not None or vmax is not None :
63336341 ret .set_clim (vmin , vmax )
6334- else :
6342+ elif np . ndim ( C ) == 2 : # C.ndim == 3 is RGB(A) so doesn't need scaling.
63356343 ret .autoscale_None ()
63366344
63376345 ret .sticky_edges .x [:] = [xl , xr ]
0 commit comments