@@ -5172,7 +5172,21 @@ def _pcolorargs(funcname, *args, **kw):
5172
5172
return X , Y , C
5173
5173
5174
5174
if len (args ) == 3 :
5175
- X , Y , C = [np .asanyarray (a ) for a in args ]
5175
+ # Check x and y for bad data...
5176
+ C = np .asanyarray (args [2 ])
5177
+ X , Y = [cbook .safe_masked_invalid (a ) for a in args [:2 ]]
5178
+ if funcname == 'pcolormesh' :
5179
+ if np .ma .is_masked (X ) or np .ma .is_masked (Y ):
5180
+ raise ValueError (
5181
+ 'x and y arguments to pcolormesh cannot have '
5182
+ 'non-finite values or be of type '
5183
+ 'numpy.ma.core.MaskedArray with masked values' )
5184
+ # safe_masked_invalid() returns an ndarray for dtypes other
5185
+ # than floating point.
5186
+ if isinstance (X , np .ma .core .MaskedArray ):
5187
+ X = X .data # strip mask as downstream doesn't like it...
5188
+ if isinstance (Y , np .ma .core .MaskedArray ):
5189
+ Y = Y .data
5176
5190
numRows , numCols = C .shape
5177
5191
else :
5178
5192
raise TypeError (
@@ -5567,7 +5581,6 @@ def pcolormesh(self, *args, **kwargs):
5567
5581
# convert to one dimensional arrays
5568
5582
C = C .ravel ()
5569
5583
coords = np .column_stack ((X , Y )).astype (float , copy = False )
5570
-
5571
5584
collection = mcoll .QuadMesh (Nx - 1 , Ny - 1 , coords ,
5572
5585
antialiased = antialiased , shading = shading ,
5573
5586
** kwargs )
0 commit comments