Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a1af30

Browse files
committed
FIX: unit-convert pcolorargs before interpolating
1 parent 5b835ee commit 9a1af30

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5422,8 +5422,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
54225422
self.add_image(im)
54235423
return im
54245424

5425-
@staticmethod
5426-
def _pcolorargs(funcname, *args, shading='flat'):
5425+
def _pcolorargs(self, funcname, *args, shading='flat', **kwargs):
54275426
# - create X and Y if not present;
54285427
# - reshape X and Y as needed if they are 1-D;
54295428
# - check for proper sizes based on `shading` kwarg;
@@ -5454,6 +5453,11 @@ def _pcolorargs(funcname, *args, shading='flat'):
54545453
# Check x and y for bad data...
54555454
C = np.asanyarray(args[2])
54565455
X, Y = [cbook.safe_masked_invalid(a) for a in args[:2]]
5456+
# unit conversion allows e.g. datetime objects as axis values
5457+
X, Y = self._process_unit_info([("x", X), ("y", Y)], kwargs)
5458+
X = self.convert_xunits(X)
5459+
Y = self.convert_yunits(Y)
5460+
54575461
if funcname == 'pcolormesh':
54585462
if np.ma.is_masked(X) or np.ma.is_masked(Y):
54595463
raise ValueError(
@@ -5702,12 +5706,10 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
57025706
if shading is None:
57035707
shading = rcParams['pcolor.shading']
57045708
shading = shading.lower()
5705-
X, Y, C, shading = self._pcolorargs('pcolor', *args, shading=shading)
5709+
X, Y, C, shading = self._pcolorargs('pcolor', *args, shading=shading,
5710+
kwargs)
57065711
Ny, Nx = X.shape
57075712

5708-
# unit conversion allows e.g. datetime objects as axis values
5709-
X, Y = self._process_unit_info([("x", X), ("y", Y)], kwargs)
5710-
57115713
# convert to MA, if necessary.
57125714
C = ma.asarray(C)
57135715
X = ma.asarray(X)
@@ -5976,12 +5978,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
59765978
kwargs.setdefault('edgecolors', 'None')
59775979

59785980
X, Y, C, shading = self._pcolorargs('pcolormesh', *args,
5979-
shading=shading)
5981+
shading=shading, kwargs)
59805982
Ny, Nx = X.shape
59815983
X = X.ravel()
59825984
Y = Y.ravel()
5983-
# unit conversion allows e.g. datetime objects as axis values
5984-
X, Y = self._process_unit_info([("x", X), ("y", Y)], kwargs)
59855985

59865986
# convert to one dimensional arrays
59875987
C = C.ravel()

0 commit comments

Comments
 (0)