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

Skip to content

Commit f9dc4b1

Browse files
committed
remove cmap in imshow and pcolorfast
1 parent bf65847 commit f9dc4b1

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
@@ -5140,8 +5140,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51405140

51415141
temp = np.asarray(X)
51425142
if temp.ndim == 3 and isinstance(norm, mcolors.BivariateNorm):
5143-
temp = norm(temp)
5144-
X = cmap(temp, alpha=self.get_alpha(), bytes=True)
5143+
X = norm(temp)
51455144

51465145
if not self._hold:
51475146
self.cla()
@@ -5775,7 +5774,6 @@ def pcolorfast(self, *args, **kwargs):
57755774
if (C.ndim == 3 and isBivari):
57765775
C = norm(C)
57775776
nr, nc = C.shape
5778-
C = cmap(C, alpha=alpha, bytes=True)
57795777
else:
57805778
nr, nc = C.shape
57815779
if len(args) == 1:

lib/matplotlib/colors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,18 @@ def reversed(self, name=None):
862862
class BivariateColormap(Colormap):
863863
def __init__(self, name='bivariate', N=256):
864864
Colormap.__init__(self, name, N)
865+
self.N = self.N * self.N
865866

866867
def _init(self):
867-
red = np.linspace(0, 1, self.N)
868-
green = np.linspace(0, 1, self.N)
868+
red = np.linspace(0, 1, np.sqrt(self.N))
869+
green = np.linspace(0, 1, np.sqrt(self.N))
869870
red_mesh, green_mesh = np.meshgrid(red, green)
870871
blue_mesh = np.zeros_like(red_mesh)
871872
alpha_mesh = np.ones_like(red_mesh)
872873
bivariate_cmap = np.dstack((red_mesh, green_mesh, blue_mesh,
873874
alpha_mesh))
874875
self._lut = np.vstack(bivariate_cmap)
875876
self._isinit = True
876-
self.N = self.N * self.N
877877
self._set_extremes()
878878

879879
def _resample(self, lutsize):

lib/matplotlib/image.py

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

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

0 commit comments

Comments
 (0)