@@ -797,14 +797,36 @@ def get_children(self):
797
797
return [self .label , self .offsetText ,
798
798
* self .get_major_ticks (), * self .get_minor_ticks ()]
799
799
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 : value for name , value in self ._major_tick_kw .items ()
809
+ if name in ['tick1On' , 'tick2On' , 'label1On' , 'label2On' ]}
801
810
self ._major_tick_kw .clear ()
811
+ if keep_tick_and_label_visibility :
812
+ self ._major_tick_kw .update (backup )
802
813
self ._major_tick_kw ['gridOn' ] = (
803
814
mpl .rcParams ['axes.grid' ] and
804
815
mpl .rcParams ['axes.grid.which' ] in ('both' , 'major' ))
805
816
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 : value for name , value in self ._minor_tick_kw .items ()
826
+ if name in ['tick1On' , 'tick2On' , 'label1On' , 'label2On' ]}
807
827
self ._minor_tick_kw .clear ()
828
+ if keep_tick_and_label_visibility :
829
+ self ._minor_tick_kw .update (backup )
808
830
self ._minor_tick_kw ['gridOn' ] = (
809
831
mpl .rcParams ['axes.grid' ] and
810
832
mpl .rcParams ['axes.grid.which' ] in ('both' , 'minor' ))
@@ -821,6 +843,8 @@ def clear(self):
821
843
- major and minor grid
822
844
- units
823
845
- registered callbacks
846
+
847
+ This does not reset tick and tick label visibility.
824
848
"""
825
849
826
850
self .label .set_text ('' ) # self.set_label_text would change isDefault_
@@ -832,12 +856,8 @@ def clear(self):
832
856
signals = ["units" , "units finalize" ])
833
857
834
858
# 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 )
841
861
self .reset_ticks ()
842
862
843
863
self .converter = None
0 commit comments