@@ -5679,7 +5679,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
5679
5679
5680
5680
if len (args ) == 1 :
5681
5681
C = np .asanyarray (args [0 ])
5682
- nrows , ncols = C .shape
5682
+ nrows , ncols = C .shape [: 2 ]
5683
5683
if shading in ['gouraud' , 'nearest' ]:
5684
5684
X , Y = np .meshgrid (np .arange (ncols ), np .arange (nrows ))
5685
5685
else :
@@ -5708,7 +5708,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
5708
5708
X = X .data # strip mask as downstream doesn't like it...
5709
5709
if isinstance (Y , np .ma .core .MaskedArray ):
5710
5710
Y = Y .data
5711
- nrows , ncols = C .shape
5711
+ nrows , ncols = C .shape [: 2 ]
5712
5712
else :
5713
5713
raise _api .nargs_error (funcname , takes = "1 or 3" , given = len (args ))
5714
5714
@@ -6045,9 +6045,18 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6045
6045
6046
6046
Parameters
6047
6047
----------
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.
6051
6060
6052
6061
X, Y : array-like, optional
6053
6062
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,
6207
6216
X , Y , C , shading = self ._pcolorargs ('pcolormesh' , * args ,
6208
6217
shading = shading , kwargs = kwargs )
6209
6218
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 ()
6212
6222
6213
6223
kwargs .setdefault ('snap' , mpl .rcParams ['pcolormesh.snap' ])
6214
6224
0 commit comments