8000 Set colorbar label only in set_label. · matplotlib/matplotlib@2a6bcd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a6bcd4

Browse files
committed
Set colorbar label only in set_label.
... instead of doing so also in _config_axis. _config_axis is also called when e.g. the norm is changed, but we don't want to reset the label in that case. Note that the previous `self._labelkw` was only usable for one colorbar orientation anyways (because the choice of `_pos_kw` depends on the orientation) so everything was already tied to a single orientation.
1 parent 8d2c16b commit 2a6bcd4

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

lib/matplotlib/colorbar.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ def _config_axis(self):
548548
ticks_position=self.ticklocation)
549549
short_axis.set_ticks([])
550550
short_axis.set_ticks([], minor=True)
551-
self._set_label()
552551

553552
def _get_ticker_locator_formatter(self):
554553
"""
@@ -726,16 +725,8 @@ def minorticks_off(self):
726725
"""Turn the minor ticks of the colorbar off."""
727726
ax = self.ax
728727
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
729-
730728
long_axis.set_minor_locator(ticker.NullLocator())
731729

732-
def _set_label(self):
733-
if self.orientation == 'vertical':
734-
self.ax.set_ylabel(self._label, **self._labelkw)
735-
else:
736-
self.ax.set_xlabel(self._label, **self._labelkw)
737-
self.stale = True
738-
739730
def set_label(self, label, *, loc=None, **kwargs):
740731
"""Add a label to the long axis of the colorbar."""
741732
_pos_xy = 'y' if self.orientation == 'vertical' else 'x'
@@ -759,9 +750,11 @@ def set_label(self, label, *, loc=None, **kwargs):
759750
elif loc in ['left', 'bottom']:
760751
kwargs[_pos_xy] = 0.
761752
kwargs['horizontalalignment'] = 'left'
762-
self._label = label
763-
self._labelkw = kwargs
764-
self._set_label()
753+
if self.orientation == 'vertical':
754+
self.ax.set_ylabel(label, **kwargs)
755+
else:
756+
self.ax.set_xlabel(label, **kwargs)
757+
self.stale = True
765758

766759
def _outline(self, X, Y):
767760
"""

0 commit comments

Comments
 (0)
0