Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor handling of tick and ticklabel visibility in Axis.clear()#22587

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:mainfromtimhoffm:refactor-tick-clearing
Mar 16, 2022
Merged
Changes fromall 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
36 changes: 28 additions & 8 deletionslib/matplotlib/axis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -781,14 +781,36 @@ def get_children(self):
return [self.label, self.offsetText,
*self.get_major_ticks(), *self.get_minor_ticks()]

def _reset_major_tick_kw(self):
def _reset_major_tick_kw(self, keep_tick_and_label_visibility=False):
"""
Reset major tick params to defaults.

Shared subplots pre-configure tick and label visibility. To keep this
beyond an Axis.clear() operation, we may
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
beyondanAxis.clear()operation,wemay
beyondan`Axis.clear()`operation,wemay

(Or something similar. If possible. For both methods.)

*keep_tick_and_label_visibility*.
"""
backup = {name: value for name, value in self._major_tick_kw.items()
if name in ['tick1On', 'tick2On', 'label1On', 'label2On']}
self._major_tick_kw.clear()
if keep_tick_and_label_visibility:
self._major_tick_kw.update(backup)
self._major_tick_kw['gridOn'] = (
mpl.rcParams['axes.grid'] and
mpl.rcParams['axes.grid.which'] in ('both', 'major'))

def _reset_minor_tick_kw(self):
def _reset_minor_tick_kw(self, keep_tick_and_label_visibility=False):
"""
Reset minor tick params to defaults.

Shared subplots pre-configure tick and label visibility. To keep this
beyond an Axis.clear() operation, we may
*keep_tick_and_label_visibility*.
"""
backup = {name: value for name, value in self._minor_tick_kw.items()
if name in ['tick1On', 'tick2On', 'label1On', 'label2On']}
self._minor_tick_kw.clear()
if keep_tick_and_label_visibility:
self._minor_tick_kw.update(backup)
self._minor_tick_kw['gridOn'] = (
mpl.rcParams['axes.grid'] and
mpl.rcParams['axes.grid.which'] in ('both', 'minor'))
Expand All@@ -805,6 +827,8 @@ def clear(self):
- major and minor grid
- units
- registered callbacks

This does not reset tick and tick label visibility.
"""

self.label.set_text('') # self.set_label_text would change isDefault_
Expand All@@ -816,12 +840,8 @@ def clear(self):
signals=["units", "units finalize"])

# whether the grids are on
self._major_tick_kw['gridOn'] = (
mpl.rcParams['axes.grid'] and
mpl.rcParams['axes.grid.which'] in ('both', 'major'))
self._minor_tick_kw['gridOn'] = (
mpl.rcParams['axes.grid'] and
mpl.rcParams['axes.grid.which'] in ('both', 'minor'))
self._reset_major_tick_kw(keep_tick_and_label_visibility=True)
self._reset_minor_tick_kw(keep_tick_and_label_visibility=True)
self.reset_ticks()

self.converter = None
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp