@@ -5172,7 +5172,21 @@ def _pcolorargs(funcname, *args, **kw):
51725172 return X , Y , C
51735173
51745174 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
51765190 numRows , numCols = C .shape
51775191 else :
51785192 raise TypeError (
@@ -5567,7 +5581,6 @@ def pcolormesh(self, *args, **kwargs):
55675581 # convert to one dimensional arrays
55685582 C = C .ravel ()
55695583 coords = np .column_stack ((X , Y )).astype (float , copy = False )
5570-
55715584 collection = mcoll .QuadMesh (Nx - 1 , Ny - 1 , coords ,
55725585 antialiased = antialiased , shading = shading ,
55735586 ** kwargs )
0 commit comments