@@ -797,14 +797,36 @@ def get_children(self):
797797return [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 :value for name ,value in self ._major_tick_kw .items ()
809+ if name in ['tick1On' ,'tick2On' ,'label1On' ,'label2On' ]}
801810self ._major_tick_kw .clear ()
811+ if keep_tick_and_label_visibility :
812+ self ._major_tick_kw .update (backup )
802813self ._major_tick_kw ['gridOn' ]= (
803814mpl .rcParams ['axes.grid' ]and
804815mpl .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 :value for name ,value in self ._minor_tick_kw .items ()
826+ if name in ['tick1On' ,'tick2On' ,'label1On' ,'label2On' ]}
807827self ._minor_tick_kw .clear ()
828+ if keep_tick_and_label_visibility :
829+ self ._minor_tick_kw .update (backup )
808830self ._minor_tick_kw ['gridOn' ]= (
809831mpl .rcParams ['axes.grid' ]and
810832mpl .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
826850self .label .set_text ('' )# self.set_label_text would change isDefault_
@@ -832,12 +856,8 @@ def clear(self):
832856signals = ["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 )
841861self .reset_ticks ()
842862
843863self .converter = None