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

Skip to content

Commit d471a21

Browse files
committed
FIX: unit-convert pcolorargs before interpolating
1 parent aa82b50 commit d471a21

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5455,8 +5455,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
54555455
self.add_image(im)
54565456
return im
54575457

5458-
@staticmethod
5459-
def _pcolorargs(funcname, *args, shading='flat'):
5458+
def _pcolorargs(self, funcname, *args, shading='flat', **kwargs):
54605459
# - create X and Y if not present;
54615460
# - reshape X and Y as needed if they are 1-D;
54625461
# - check for proper sizes based on `shading` kwarg;
@@ -5487,6 +5486,11 @@ def _pcolorargs(funcname, *args, shading='flat'):
54875486
# Check x and y for bad data...
54885487
C = np.asanyarray(args[2])
54895488
X, Y = [cbook.safe_masked_invalid(a) for a in args[:2]]
5489+
# unit conversion allows e.g. datetime objects as axis values
5490+
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
5491+
X = self.convert_xunits(X)
5492+
Y = self.convert_yunits(Y)
5493+
54905494
if funcname == 'pcolormesh':
54915495
if np.ma.is_masked(X) or np.ma.is_masked(Y):
54925496
raise ValueError(
@@ -5735,14 +5739,10 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
57355739
if shading is None:
57365740
shading = rcParams['pcolor.shading']
57375741
shading = shading.lower()
5738-
X, Y, C, shading = self._pcolorargs('pcolor', *args, shading=shading)
5742+
X, Y, C, shading = self._pcolorargs('pcolor', *args, shading=shading,
5743+
**kwargs)
57395744
Ny, Nx = X.shape
57405745

5741-
# unit conversion allows e.g. datetime objects as axis values
5742-
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
5743-
X = self.convert_xunits(X)
5744-
Y = self.convert_yunits(Y)
5745-
57465746
# convert to MA, if necessary.
57475747
C = ma.asarray(C)
57485748
X = ma.asarray(X)
@@ -6011,14 +6011,10 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60116011
kwargs.setdefault('edgecolors', 'None')
60126012

60136013
X, Y, C, shading = self._pcolorargs('pcolormesh', *args,
6014-
shading=shading)
6014+
shading=shading, **kwargs)
60156015
Ny, Nx = X.shape
60166016
X = X.ravel()
60176017
Y = Y.ravel()
6018-
# unit conversion allows e.g. datetime objects as axis values
6019-
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
6020-
X = self.convert_xunits(X)
6021-
Y = self.convert_yunits(Y)
60226018

60236019
# convert to one dimensional arrays
60246020
C = C.ravel()

0 commit comments

Comments
 (0)