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

Commit945692c

Browse files
authored
Merge pull request#22587 from timhoffm/refactor-tick-clearing
Refactor handling of tick and ticklabel visiblity in Axis.clear()
2 parents223b2b1 +2357c92 commit945692c

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

‎lib/matplotlib/axis.py‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,36 @@ def get_children(self):
797797
return [self.label,self.offsetText,
798798
*self.get_major_ticks(),*self.get_minor_ticks()]
799799

800-
def_reset_major_tick_kw(self):
800+
def_reset_major_tick_kw(self,keep_tick_and_label_visibility=False):
801+
"""
802+
Reset major tick params to defaults.
803+
804+
Shared subplots pre-configure tick and label visibility. To keep this
805+
beyond an Axis.clear() operation, we may
806+
*keep_tick_and_label_visibility*.
807+
"""
808+
backup= {name:valueforname,valueinself._major_tick_kw.items()
809+
ifnamein ['tick1On','tick2On','label1On','label2On']}
801810
self._major_tick_kw.clear()
811+
ifkeep_tick_and_label_visibility:
812+
self._major_tick_kw.update(backup)
802813
self._major_tick_kw['gridOn']= (
803814
mpl.rcParams['axes.grid']and
804815
mpl.rcParams['axes.grid.which']in ('both','major'))
805816

806-
def_reset_minor_tick_kw(self):
817+
def_reset_minor_tick_kw(self,keep_tick_and_label_visibility=False):
818+
"""
819+
Reset minor tick params to defaults.
820+
821+
Shared subplots pre-configure tick and label visibility. To keep this
822+
beyond an Axis.clear() operation, we may
823+
*keep_tick_and_label_visibility*.
824+
"""
825+
backup= {name:valueforname,valueinself._minor_tick_kw.items()
826+
ifnamein ['tick1On','tick2On','label1On','label2On']}
807827
self._minor_tick_kw.clear()
828+
ifkeep_tick_and_label_visibility:
829+
self._minor_tick_kw.update(backup)
808830
self._minor_tick_kw['gridOn']= (
809831
mpl.rcParams['axes.grid']and
810832
mpl.rcParams['axes.grid.which']in ('both','minor'))
@@ -821,6 +843,8 @@ def clear(self):
821843
- major and minor grid
822844
- units
823845
- registered callbacks
846+
847+
This does not reset tick and tick label visibility.
824848
"""
825849

826850
self.label.set_text('')# self.set_label_text would change isDefault_
@@ -832,12 +856,8 @@ def clear(self):
832856
signals=["units","units finalize"])
833857

834858
# whether the grids are on
835-
self._major_tick_kw['gridOn']= (
836-
mpl.rcParams['axes.grid']and
837-
mpl.rcParams['axes.grid.which']in ('both','major'))
838-
self._minor_tick_kw['gridOn']= (
839-
mpl.rcParams['axes.grid']and
840-
mpl.rcParams['axes.grid.which']in ('both','minor'))
859+
self._reset_major_tick_kw(keep_tick_and_label_visibility=True)
860+
self._reset_minor_tick_kw(keep_tick_and_label_visibility=True)
841861
self.reset_ticks()
842862

843863
self.converter=None

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp