@@ -781,14 +781,36 @@ def get_children(self):
781
781
return [self .label , self .offsetText ,
782
782
* self .get_major_ticks (), * self .get_minor_ticks ()]
783
783
784
- def _reset_major_tick_kw (self ):
784
+ def _reset_major_tick_kw (self , keep_tick_and_label_visibility = False ):
785
+ """
786
+ Reset major tick params to defaults.
787
+
788
+ Shared subplots pre-configure tick and label visibility. To keep this
789
+ beyond an Axis.clear() operation, we may
790
+ *keep_tick_and_label_visibility*.
791
+ """
792
+ backup = {name : value for name , value in self ._major_tick_kw .items ()
793
+ if name in ['tick1On' , 'tick2On' , 'label1On' , 'label2On' ]}
785
794
self ._major_tick_kw .clear ()
795
+ if keep_tick_and_label_visibility :
796
+ self ._major_tick_kw .update (backup )
786
797
self ._major_tick_kw ['gridOn' ] = (
787
798
mpl .rcParams ['axes.grid' ] and
788
799
mpl .rcParams ['axes.grid.which' ] in ('both' , 'major' ))
789
800
790
- def _reset_minor_tick_kw (self ):
801
+ def _reset_minor_tick_kw (self , keep_tick_and_label_visibility = False ):
802
+ """
803
+ Reset minor tick params to defaults.
804
+
805
+ Shared subplots pre-configure tick and label visibility. To keep this
806
+ beyond an Axis.clear() operation, we may
807
+ *keep_tick_and_label_visibility*.
808
+ """
809
+ backup = {name : value for name , value in self ._minor_tick_kw .items ()
810
+ if name in ['tick1On' , 'tick2On' , 'label1On' , 'label2On' ]}
791
811
self ._minor_tick_kw .clear ()
812
+ if keep_tick_and_label_visibility :
813
+ self ._minor_tick_kw .update (backup )
792
814
self ._minor_tick_kw ['gridOn' ] = (
793
815
mpl .rcParams ['axes.grid' ] and
794
816
mpl .rcParams ['axes.grid.which' ] in ('both' , 'minor' ))
@@ -805,6 +827,8 @@ def clear(self):
805
827
- major and minor grid
806
828
- units
807
829
- registered callbacks
830
+
831
+ This does not reset tick and tick label visibility.
808
832
"""
809
833
810
834
self .label .set_text ('' ) # self.set_label_text would change isDefault_
@@ -816,12 +840,8 @@ def clear(self):
816
840
signals = ["units" , "units finalize" ])
817
841
818
842
# whether the grids are on
819
- self ._major_tick_kw ['gridOn' ] = (
820
- mpl .rcParams ['axes.grid' ] and
821
- mpl .rcParams ['axes.grid.which' ] in ('both' , 'major' ))
822
- self ._minor_tick_kw ['gridOn' ] = (
823
- mpl .rcParams ['axes.grid' ] and
824
- mpl .rcParams ['axes.grid.which' ] in ('both' , 'minor' ))
843
+ self ._reset_major_tick_kw (keep_tick_and_label_visibility = True )
844
+ self ._reset_minor_tick_kw (keep_tick_and_label_visibility = True )
825
845
self .reset_ticks ()
826
846
827
847
self .converter = None
0 commit comments