|
11 | 11 | End-users most likely won't need to directly use this module's API.
|
12 | 12 | """
|
13 | 13 |
|
14 |
| -import copy |
15 | 14 | import logging
|
16 | 15 | import textwrap
|
17 | 16 |
|
18 | 17 | import numpy as np
|
19 | 18 |
|
20 | 19 | import matplotlib as mpl
|
21 |
| -from matplotlib import _api, collections, cm, colors, contour, ticker |
| 20 | +from matplotlib import _api, cbook, collections, cm, colors, contour, ticker |
22 | 21 | import matplotlib.artist as martist
|
23 | 22 | import matplotlib.patches as mpatches
|
24 | 23 | import matplotlib.path as mpath
|
@@ -1158,22 +1157,22 @@ def _mesh(self):
|
1158 | 1157 | # vmax of the colorbar, not the norm. This allows the situation
|
1159 | 1158 | # where the colormap has a narrower range than the colorbar, to
|
1160 | 1159 | # accommodate extra contours:
|
1161 |
| - norm = copy.deepcopy(self.norm) |
1162 |
| - norm.vmin = self.vmin |
1163 |
| - norm.vmax = self.vmax |
1164 |
| - y, extendlen = self._proportional_y() |
1165 |
| - # invert: |
1166 |
| - if (isinstance(norm, (colors.BoundaryNorm, colors.NoNorm)) or |
1167 |
| - self.boundaries is not None): |
1168 |
| - y = y * (self.vmax - self.vmin) + self.vmin # not using a norm. |
1169 |
| - else: |
1170 |
| - y = norm.inverse(y) |
1171 |
| - self._y = y |
1172 |
| - X, Y = np.meshgrid([0., 1.], y) |
1173 |
| - if self.orientation == 'vertical': |
1174 |
| - return (X, Y, extendlen) |
1175 |
| - else: |
1176 |
| - return (Y, X, extendlen) |
| 1160 | + with self.norm.callbacks.blocked(), \ |
| 1161 | + cbook._setattr_cm(self.norm, vmin=self.vmin, vmax=self.vmax): |
| 1162 | + y, extendlen = self._proportional_y() |
| 1163 | + # invert: |
| 1164 | + if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm)) |
| 1165 | + or self.boundaries is not None): |
| 1166 | + # not using a norm. |
| 1167 | + y = y * (self.vmax - self.vmin) + self.vmin |
| 1168 | + else: |
| 1169 | + y = self.norm.inverse(y) |
| 1170 | + self._y = y |
| 1171 | + X, Y = np.meshgrid([0., 1.], y) |
| 1172 | + if self.orientation == 'vertical': |
| 1173 | + return (X, Y, extendlen) |
| 1174 | + else: |
| 1175 | + return (Y, X, extendlen) |
1177 | 1176 |
|
1178 | 1177 | def _forward_boundaries(self, x):
|
1179 | 1178 | # map boundaries equally between 0 and 1...
|
|
0 commit comments