@@ -5679,7 +5679,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
56795679
56805680 if len (args ) == 1 :
56815681 C = np .asanyarray (args [0 ])
5682- nrows , ncols = C .shape
5682+ nrows , ncols = C .shape [: 2 ]
56835683 if shading in ['gouraud' , 'nearest' ]:
56845684 X , Y = np .meshgrid (np .arange (ncols ), np .arange (nrows ))
56855685 else :
@@ -5708,7 +5708,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
57085708 X = X .data # strip mask as downstream doesn't like it...
57095709 if isinstance (Y , np .ma .core .MaskedArray ):
57105710 Y = Y .data
5711- nrows , ncols = C .shape
5711+ nrows , ncols = C .shape [: 2 ]
57125712 else :
57135713 raise _api .nargs_error (funcname , takes = "1 or 3" , given = len (args ))
57145714
@@ -6045,9 +6045,18 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60456045
60466046 Parameters
60476047 ----------
6048- C : 2D array-like
6049- The color-mapped values. Color-mapping is controlled by *cmap*,
6050- *norm*, *vmin*, and *vmax*.
6048+ C : array-like
6049+ The mesh data. Supported array shapes are:
6050+
6051+ - (M, N) or M*N: a mesh with scalar data. The values are mapped to
6052+ colors using normalization and a colormap. See parameters *norm*,
6053+ *cmap*, *vmin*, *vmax*.
6054+ - (M, N, 3): an image with RGB values (0-1 float or 0-255 int).
6055+ - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),
6056+ i.e. including transparency.
6057+
6058+ The first two dimensions (M, N) define the rows and columns of
6059+ the mesh data.
60516060
60526061 X, Y : array-like, optional
60536062 The coordinates of the corners of quadrilaterals of a pcolormesh::
@@ -6207,8 +6216,9 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62076216 X , Y , C , shading = self ._pcolorargs ('pcolormesh' , * args ,
62086217 shading = shading , kwargs = kwargs )
62096218 coords = np .stack ([X , Y ], axis = - 1 )
6210- # convert to one dimensional array
6211- C = C .ravel ()
6219+ # convert to one dimensional array, except for 3D RGB(A) arrays
6220+ if C .ndim != 3 :
6221+ C = C .ravel ()
62126222
62136223 kwargs .setdefault ('snap' , mpl .rcParams ['pcolormesh.snap' ])
62146224
0 commit comments