@@ -781,14 +781,36 @@ def get_children(self):
781781return [self .label ,self .offsetText ,
782782* self .get_major_ticks (),* self .get_minor_ticks ()]
783783
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' ]}
785794self ._major_tick_kw .clear ()
795+ if keep_tick_and_label_visibility :
796+ self ._major_tick_kw .update (backup )
786797self ._major_tick_kw ['gridOn' ]= (
787798mpl .rcParams ['axes.grid' ]and
788799mpl .rcParams ['axes.grid.which' ]in ('both' ,'major' ))
789800
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' ]}
791811self ._minor_tick_kw .clear ()
812+ if keep_tick_and_label_visibility :
813+ self ._minor_tick_kw .update (backup )
792814self ._minor_tick_kw ['gridOn' ]= (
793815mpl .rcParams ['axes.grid' ]and
794816mpl .rcParams ['axes.grid.which' ]in ('both' ,'minor' ))
@@ -805,6 +827,8 @@ def clear(self):
805827 - major and minor grid
806828 - units
807829 - registered callbacks
830+
831+ This does not reset tick and tick label visibility.
808832 """
809833
810834self .label .set_text ('' )# self.set_label_text would change isDefault_
@@ -816,12 +840,8 @@ def clear(self):
816840signals = ["units" ,"units finalize" ])
817841
818842# 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 )
825845self .reset_ticks ()
826846
827847self .converter = None