Skip to content

Commit 0300161

Browse files
committed
FIX: make changing norm reset locator and formatter
1 parent 107246d commit 0300161

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/matplotlib/colorbar.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,8 @@ def update_ticks(self):
531531
# get the locator and formatter. Defaults to
532532
# self.locator if not None..
533533
locator, formatter = self._get_ticker_locator_formatter()
534+
self.locator = locator
535+
self.formatter = formatter
534536
if self.orientation == 'vertical':
535537
long_axis, short_axis = ax.yaxis, ax.xaxis
536538
else:
@@ -1140,11 +1142,16 @@ def update_normal(self, mappable):
11401142
Update solid patches, lines, etc.
11411143
11421144
Unlike `.update_bruteforce`, this does not clear the axes. This is
1143-
meant to be called when the image or contour plot to which this
1144-
colorbar belongs changes.
1145+
meant to be called when the norm of the image or contour plot to which
1146+
this colorbar belongs changes.
1147+
1148+
This resets the locator and formatter for the axis, so if these
1149+
have been customized, they will need to be customized again.
11451150
"""
11461151

11471152
self.norm = self.mappable.norm
1153+
self.locator = None
1154+
self.formatter = None
11481155
self.draw_all()
11491156
if isinstance(self.mappable, contour.ContourSet):
11501157
CS = self.mappable
@@ -1166,6 +1173,10 @@ def update_bruteforce(self, mappable):
11661173
# properties have been changed by methods other than the
11671174
# colorbar methods, those changes will be lost.
11681175
self.ax.cla()
1176+
self.locator = None
1177+
self.formatter = None
1178+
self.mappable = mappable
1179+
11691180
# clearing the axes will delete outline, patch, solids, and lines:
11701181
self.outline = None
11711182
self.patch = None

0 commit comments

Comments
 (0)