Skip to content

Commit 68e9b15

Browse files
anntzerQuLogic
authored andcommitted
Small cleanups to colorbar.
- `__scale = "manual"` doesn't exist anymore since d1c5a6a. - Shorten Boundary/NoNorm inversion and norm._scale check. - No need to define `x` well before its use point, and no need to make it an array explicitly.
1 parent a7e05bd commit 68e9b15

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/matplotlib/colorbar.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,18 +1132,14 @@ def _mesh(self):
11321132
norm = copy.deepcopy(self.norm)
11331133
norm.vmin = self.vmin
11341134
norm.vmax = self.vmax
1135-
x = np.array([0.0, 1.0])
11361135
y, extendlen = self._proportional_y()
11371136
# invert:
1138-
if (isinstance(norm, (colors.BoundaryNorm, colors.NoNorm)) or
1139-
(self.__scale == 'manual')):
1140-
# if a norm doesn't have a named scale, or we are not using a norm:
1141-
dv = self.vmax - self.vmin
1142-
y = y * dv + self.vmin
1137+
if isinstance(norm, (colors.BoundaryNorm, colors.NoNorm)):
1138+
y = y * (self.vmax - self.vmin) + self.vmin # not using a norm.
11431139
else:
11441140
y = norm.inverse(y)
11451141
self._y = y
1146-
X, Y = np.meshgrid(x, y)
1142+
X, Y = np.meshgrid([0., 1.], y)
11471143
if self.orientation == 'vertical':
11481144
return (X, Y, extendlen)
11491145
else:
@@ -1183,8 +1179,8 @@ def _reset_locator_formatter_scale(self):
11831179
self._set_scale('function', functions=funcs)
11841180
elif self.spacing == 'proportional':
11851181
self._set_scale('linear')
1186-
elif hasattr(self.norm, '_scale') and self.norm._scale is not None:
1187-
# use the norm's scale:
1182+
elif getattr(self.norm, '_scale', None):
1183+
# use the norm's scale (if it exists and is not None):
11881184
self._set_scale(self.norm._scale)
11891185
elif type(self.norm) is colors.Normalize:
11901186
# plain Normalize:

0 commit comments

Comments
 (0)