Skip to content

Commit a5cd938

Browse files
committed
remove cmap in imshow and pcolorfast
1 parent 4dadbe3 commit a5cd938

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5122,8 +5122,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51225122

51235123
temp = np.asarray(X)
51245124
if temp.ndim == 3 and isinstance(norm, mcolors.BivariateNorm):
5125-
temp = norm(temp)
5126-
X = cmap(temp, alpha=self.get_alpha(), bytes=True)
5125+
X = norm(temp)
51275126

51285127
if not self._hold:
51295128
self.cla()
@@ -5760,7 +5759,6 @@ def pcolorfast(self, *args, **kwargs):
57605759
if (C.ndim == 3 and isBivari):
57615760
C = norm(C)
57625761
nr, nc = C.shape
5763-
C = cmap(C, alpha=alpha, bytes=True)
57645762
else:
57655763
nr, nc = C.shape
57665764
if len(args) == 1:

lib/matplotlib/colors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,18 +859,18 @@ def reversed(self, name=None):
859859
class BivariateColormap(Colormap):
860860
def __init__(self, name='bivariate', N=256):
861861
Colormap.__init__(self, name, N)
862+
self.N = self.N * self.N
862863

863864
def _init(self):
864-
red = np.linspace(0, 1, self.N)
865-
green = np.linspace(0, 1, self.N)
865+
red = np.linspace(0, 1, np.sqrt(self.N))
866+
green = np.linspace(0, 1, np.sqrt(self.N))
866867
red_mesh, green_mesh = np.meshgrid(red, green)
867868
blue_mesh = np.zeros_like(red_mesh)
868869
alpha_mesh = np.ones_like(red_mesh)
869870
bivariate_cmap = np.dstack((red_mesh, green_mesh, blue_mesh,
870871
alpha_mesh))
871872
self._lut = np.vstack(bivariate_cmap)
872873
self._isinit = True
873-
self.N = self.N * self.N
874874
self._set_extremes()
875875

876876
def _resample(self, lutsize):

lib/matplotlib/image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
362362
raise ValueError("Invalid dimensions, got {}".format(A.shape))
363363

364364
if A.ndim == 2:
365-
A = self.norm(A)
365+
if not isinstance(self.norm, mcolors.BivariateNorm):
366+
A = self.norm(A)
366367
if A.dtype.kind == 'f':
367368
# If the image is greyscale, convert to RGBA and
368369
# use the extra channels for resizing the over,

0 commit comments

Comments
 (0)