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

Skip to content

Commit d54cb44

Browse files
committed
Make pcolor work with bivariate
1 parent 8f6928d commit d54cb44

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5408,10 +5408,6 @@ def pcolor(self, *args, **kwargs):
54085408
X, Y, C = self._pcolorargs('pcolor', *args, **kw)
54095409
Ny, Nx = X.shape
54105410

5411-
if (isinstance(norm, mcolors.BivariateNorm) or
5412-
isinstance(cmap, mcolors.BivariateColormap)):
5413-
norm = mcolors.NoNorm()
5414-
54155411
# unit conversion allows e.g. datetime objects as axis values
54165412
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
54175413
X = self.convert_xunits(X)
@@ -5426,7 +5422,10 @@ def pcolor(self, *args, **kwargs):
54265422
xymask = (mask[0:-1, 0:-1] + mask[1:, 1:] +
54275423
mask[0:-1, 1:] + mask[1:, 0:-1])
54285424
# don't plot if C or any of the surrounding vertices are masked.
5429-
mask = ma.getmaskarray(C) + xymask
5425+
if isinstance(norm, mcolors.BivariateNorm):
5426+
mask = ma.getmaskarray(C[0]) + ma.getmaskarray(C[1]) + xymask
5427+
else:
5428+
mask = ma.getmaskarray(C) + xymask
54305429

54315430
newaxis = np.newaxis
54325431
compress = np.compress
@@ -5450,7 +5449,14 @@ def pcolor(self, *args, **kwargs):
54505449
axis=1)
54515450
verts = xy.reshape((npoly, 5, 2))
54525451

5453-
C = compress(ravelmask, ma.filled(C[0:Ny - 1, 0:Nx - 1]).ravel())
5452+
if isinstance(norm, mcolors.BivariateNorm):
5453+
C0 = C[0]
5454+
C1 = C[1]
5455+
C0 = compress(ravelmask, ma.filled(C0[0:Ny - 1, 0:Nx - 1]).ravel())
5456+
C1 = compress(ravelmask, ma.filled(C1[0:Ny - 1, 0:Nx - 1]).ravel())
5457+
C = np.array([C0, C1])
5458+
else:
5459+
C = compress(ravelmask, ma.filled(C[0:Ny - 1, 0:Nx - 1]).ravel())
54545460

54555461
linewidths = (0.25,)
54565462
if 'linewidth' in kwargs:
@@ -5769,8 +5775,7 @@ def pcolorfast(self, *args, **kwargs):
57695775
isBivari = (isinstance(norm, mcolors.BivariateNorm)
57705776
or isinstance(cmap, mcolors.BivariateColormap))
57715777
if (C.ndim == 3 and isBivari):
5772-
C = norm(C)
5773-
nr, nc = C.shape
5778+
nr, nc = C.shape[1:]
57745779
else:
57755780
nr, nc = C.shape
57765781
if len(args) == 1:

0 commit comments

Comments
 (0)