@@ -5182,7 +5182,21 @@ def _pcolorargs(funcname, *args, **kw):
5182
5182
return X , Y , C
5183
5183
5184
5184
if len (args ) == 3 :
5185
- X , Y , C = [np .asanyarray (a ) for a in args ]
5185
+ # Check x and y for bad data...
5186
+ C = np .asanyarray (args [2 ])
5187
+ X , Y = [cbook .safe_masked_invalid (a ) for a in args [:2 ]]
5188
+ if funcname == 'pcolormesh' :
5189
+ if np .ma .is_masked (X ) or np .ma .is_masked (Y ):
5190
+ raise ValueError (
5191
+ 'x and y arguments to pcolormesh cannot have '
5192
+ 'non-finite values or be of type '
5193
+ 'numpy.ma.core.MaskedArray with masked values' )
5194
+ # safe_masked_invalid() returns an ndarray for dtypes other
5195
+ # than floating point.
5196
+ if isinstance (X , np .ma .core .MaskedArray ):
5197
+ X = X .data # strip mask as downstream doesn't like it...
5198
+ if isinstance (Y , np .ma .core .MaskedArray ):
5199
+ Y = Y .data
5186
5200
numRows , numCols = C .shape
5187
5201
else :
5188
5202
raise TypeError (
@@ -5577,7 +5591,6 @@ def pcolormesh(self, *args, **kwargs):
5577
5591
# convert to one dimensional arrays
5578
5592
C = C .ravel ()
5579
5593
coords = np .column_stack ((X , Y )).astype (float , copy = False )
5580
-
5581
5594
collection = mcoll .QuadMesh (Nx - 1 , Ny - 1 , coords ,
5582
5595
antialiased = antialiased , shading = shading ,
5583
5596
** kwargs )
0 commit comments