8000 Merge pull request #21137 from anntzer/cb · matplotlib/matplotlib@2b15797 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b15797

Browse files
authored
Merge pull request #21137 from anntzer/cb
Small cleanups to colorbar.
2 parents c757fe1 + 3b52c10 commit 2b15797

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
@@ -1106,18 +1106,14 @@ def _mesh(self):
11061106
norm = copy.deepcopy(self.norm)
11071107
norm.vmin = self.vmin
11081108
norm.vmax = self.vmax
1109-
x = np.array([0.0, 1.0])
11101109
y, extendlen = self._proportional_y()
11111110
# invert:
1112-
if (isinstance(norm, (colors.BoundaryNorm, colors.NoNorm)) or
1113-
(self.__scale == 'manual')):
1114-
# if a norm doesn't have a named scale, or we are not using a norm:
1115-
dv = self.vmax - self.vmin
1116-
y = y * dv + self.vmin
1111+
if isinstance(norm, (colors.BoundaryNorm, colors.NoNorm)):
1112+
y = y * (self.vmax - self.vmin) + self.vmin # not using a norm.
11171113
else:
11181114
y = norm.inverse(y)
11191115
self._y = y
1120-
X, Y = np.meshgrid(x, y)
1116+
X, Y = np.meshgrid([0., 1.], y)
11211117
if self.orientation == 'vertical':
11221118
return (X, Y, extendlen)
11231119
else:
@@ -1152,8 +1148,8 @@ def _reset_locator_formatter_scale(self):
11521148
self._set_scale('function', functions=funcs)
11531149
elif self.spacing == 'proportional':
11541150
self._set_scale('linear')
1155-
elif hasattr(self.norm, '_scale') and self.norm._scale is not None:
1156-
# use the norm's scale:
1151+
elif getattr(self.norm, '_scale', None):
1152+
# use the norm's scale (if it exists and is not None):
11571153
self._set_scale(self.norm._scale)
11581154
elif type(self.norm) is colors.Normalize:
11591155
# plain Normalize:

0 commit comments

Comments
 (0)
0