@@ -5182,7 +5182,21 @@ def _pcolorargs(funcname, *args, **kw):
51825182 return X , Y , C
51835183
51845184 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
51865200 numRows , numCols = C .shape
51875201 else :
51885202 raise TypeError (
@@ -5577,7 +5591,6 @@ def pcolormesh(self, *args, **kwargs):
55775591 # convert to one dimensional arrays
55785592 C = C .ravel ()
55795593 coords = np .column_stack ((X , Y )).astype (float , copy = False )
5580-
55815594 collection = mcoll .QuadMesh (Nx - 1 , Ny - 1 , coords ,
55825595 antialiased = antialiased , shading = shading ,
55835596 ** kwargs )
0 commit comments