8000 Set colorbar label only in set_label. by anntzer · Pull Request #17806 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Set colorbar label only in set_label. #17806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _config_axis(self):
ticks_position=self.ticklocation)
short_axis.set_ticks([])
short_axis.set_ticks([], minor=True)
self._set_label()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still make sense to set self.stale = True here though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed.

self.stale = True

def _get_ticker_locator_formatter(self):
"""
Expand Down Expand Up @@ -726,16 +726,8 @@ def minorticks_off(self):
"""Turn the minor ticks of the colorbar off."""
ax = self.ax
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis

long_axis.set_minor_locator(ticker.NullLocator())

def _set_label(self):
if self.orientation == 'vertical':
self.ax.set_ylabel(self._label, **self._labelkw)
else:
self.ax.set_xlabel(self._label, **self._labelkw)
self.stale = True

def set_label(self, label, *, loc=None, **kwargs):
"""Add a label to the long axis of the colorbar."""
_pos_xy = 'y' if self.orientation == 'vertical' else 'x'
Expand All @@ -759,9 +751,11 @@ def set_label(self, label, *, loc=None, **kwargs):
elif loc in ['left', 'bottom']:
kwargs[_pos_xy] = 0.
kwargs['horizontalalignment'] = 'left'
self._label = label
self._labelkw = kwargs
self._set_label()
if self.orientation == 'vertical':
self.ax.set_ylabel(label, **kwargs)
else:
self.ax.set_xlabel(label, **kwargs)
self.stale = True

def _outline(self, X, Y):
"""
Expand Down
0