@@ -5806,9 +5806,13 @@ def _interp_grid(X):
5806
5806
"This may lead to incorrectly calculated cell "
5807
5807
"edges, in which case, please supply "
5808
5808
f"explicit cell edges to { funcname } ." )
5809
- X = np .hstack ((X [:, [0 ]] - dX [:, [0 ]],
5810
- X [:, :- 1 ] + dX ,
5811
- X [:, [- 1 ]] + dX [:, [- 1 ]]))
5809
+ if isinstance (X , np .ma .core .MaskedArray ):
5810
+ hstack = np .ma .hstack
5811
+ else :
5812
+ hstack = np .hstack
5813
+ X = hstack ((X [:, [0 ]] - dX [:, [0 ]],
5814
+ X [:, :- 1 ] + dX ,
5815
+ X [:, [- 1 ]] + dX [:, [- 1 ]]))
5812
5816
else :
5813
5817
# This is just degenerate, but we can't reliably guess
5814
5818
# a dX if there is just one value.
@@ -5926,7 +5930,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5926
5930
5927
5931
Returns
5928
5932
-------
5929
- `matplotlib.collections.Collection `
5933
+ `matplotlib.collections.PolyQuadMesh `
5930
5934
5931
5935
Other Parameters
5932
5936
----------------
@@ -5944,7 +5948,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5944
5948
5945
5949
**kwargs
5946
5950
Additionally, the following arguments are allowed. They are passed
5947
- along to the `~matplotlib.collections.PolyCollection ` constructor:
5951
+ along to the `~matplotlib.collections.PolyQuadMesh ` constructor:
5948
5952
5949
5953
%(PolyCollection:kwdoc)s
5950
5954
@@ -5978,35 +5982,6 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5978
5982
shading = shading .lower ()
5979
5983
X , Y , C , shading = self ._pcolorargs ('pcolor' , * args , shading = shading ,
5980
5984
kwargs = kwargs )
5981
- Ny , Nx = X .shape
5982
-
5983
- # convert to MA, if necessary.
5984
- C = ma .asarray (C )
5985
- X = ma .asarray (X )
5986
- Y = ma .asarray (Y )
5987
-
5988
- mask = ma .getmaskarray (X ) + ma .getmaskarray (Y )
5989
- xymask = (mask [0 :- 1 , 0 :- 1 ] + mask [1 :, 1 :] +
5990
- mask [0 :- 1 , 1 :] + mask [1 :, 0 :- 1 ])
5991
- # don't plot if C or any of the surrounding vertices are masked.
5992
- mask = ma .getmaskarray (C ) + xymask
5993
-
5994
- unmask = ~ mask
5995
- X1 = ma .filled (X [:- 1 , :- 1 ])[unmask ]
5996
- Y1 = ma .filled (Y [:- 1 , :- 1 ])[unmask ]
5997
- X2 = ma .filled (X [1 :, :- 1 ])[unmask ]
5998
- Y2 = ma .filled (Y [1 :, :- 1 ])[unmask ]
5999
- X3 = ma .filled (X [1 :, 1 :])[unmask ]
6000
- Y3 = ma .filled (Y [1 :, 1 :])[unmask ]
6001
- X4 = ma .filled (X [:- 1 , 1 :])[unmask ]
6002
- Y4 = ma .filled (Y [:- 1 , 1 :])[unmask ]
6003
- npoly = len (X1 )
6004
-
6005
- xy = np .stack ([X1 , Y1 , X2 , Y2 , X3 , Y3 , X4 , Y4 , X1 , Y1 ], axis = - 1 )
6006
- verts = xy .reshape ((npoly , 5 , 2 ))
6007
-
6008
- C = ma .filled (C [:Ny - 1 , :Nx - 1 ])[unmask ]
6009
-
6010
5985
linewidths = (0.25 ,)
6011
5986
if 'linewidth' in kwargs :
6012
5987
kwargs ['linewidths' ] = kwargs .pop ('linewidth' )
@@ -6020,19 +5995,30 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
6020
5995
# unless the boundary is not stroked, in which case the
6021
5996
# default will be False; with unstroked boundaries, aa
6022
5997
# makes artifacts that are often disturbing.
6023
- if 'antialiased ' in kwargs :
6024
- kwargs ['antialiaseds ' ] = kwargs .pop ('antialiased ' )
6025
- if 'antialiaseds ' not in kwargs and cbook ._str_lower_equal (ec , "none" ):
6026
- kwargs ['antialiaseds ' ] = False
5998
+ if 'antialiaseds ' in kwargs :
5999
+ kwargs ['antialiased ' ] = kwargs .pop ('antialiaseds ' )
6000
+ if 'antialiased ' not in kwargs and cbook ._str_lower_equal (ec , "none" ):
6001
+ kwargs ['antialiased ' ] = False
6027
6002
6028
6003
kwargs .setdefault ('snap' , False )
6029
6004
6030
- collection = mcoll .PolyCollection (
6031
- verts , array = C , cmap = cmap , norm = norm , alpha = alpha , ** kwargs )
6032
- collection ._scale_norm (norm , vmin , vmax )
6005
+ if (isinstance (X , np .ma .MaskedArray )
6006
+ or isinstance (Y , np .ma .MaskedArray )):
6007
+ stack = np .ma .stack
6008
+ X = np .ma .asarray (X )
6009
+ Y = np .ma .asarray (Y )
6010
+ # For bounds collections later
6011
+ x = X .compressed ()
6012
+ y = Y .compressed ()
6013
+ else :
6014
+ stack = np .stack
6015
+ x = X
6016
+ y = Y
6017
+ coords = stack ([X , Y ], axis = - 1 )
6033
6018
6034
- x = X .compressed ()
6035
- y = Y .compressed ()
6019
+ collection = mcoll .PolyQuadMesh (
6020
+ coords , array = C , cmap = cmap , norm = norm , alpha = alpha , ** kwargs )
6021
+ collection ._scale_norm (norm , vmin , vmax )
6036
6022
6037
6023
# Transform from native to data coordinates?
6038
6024
t = collection ._transform
0 commit comments