@@ -481,6 +481,7 @@ def __init__(self, fig, rect,
481481 """ % {'scale' : ' | ' .join (
482482 [repr (x ) for x in mscale .get_scale_names ()])}
483483 martist .Artist .__init__ (self )
484+ self ._in_init = True
484485 if isinstance (rect , mtransforms .Bbox ):
485486 self ._position = rect
486487 else :
@@ -578,6 +579,8 @@ def __init__(self, fig, rect,
578579 right = rcParams ['ytick.right' ] and rcParams ['ytick.major.right' ],
579580 which = 'major' )
580581
582+ self ._in_init = False
583+
581584 def __getstate__ (self ):
582585 # The renderer should be re-created by the figure, and then cached at
583586 # that point.
@@ -609,11 +612,11 @@ def get_window_extent(self, *args, **kwargs):
609612 def _init_axis (self ):
610613 "move this out of __init__ because non-separable axes don't use it"
611614 self .xaxis = maxis .XAxis (self )
612- self .spines ['bottom' ].register_axis (self .xaxis )
613- self .spines ['top' ].register_axis (self .xaxis )
615+ self .spines ['bottom' ].register_axis (self .xaxis , _init = True )
616+ self .spines ['top' ].register_axis (self .xaxis , _init = True )
614617 self .yaxis = maxis .YAxis (self )
615- self .spines ['left' ].register_axis (self .yaxis )
616- self .spines ['right' ].register_axis (self .yaxis )
618+ self .spines ['left' ].register_axis (self .yaxis , _init = True )
619+ self .spines ['right' ].register_axis (self .yaxis , _init = True )
617620 self ._update_transScale ()
618621
619622 def set_figure (self , fig ):
@@ -977,10 +980,13 @@ def cla(self):
977980 xaxis_visible = self .xaxis .get_visible ()
978981 yaxis_visible = self .yaxis .get_visible ()
979982
980- self .xaxis .cla ()
981- self .yaxis .cla ()
982- for name , spine in six .iteritems (self .spines ):
983- spine .cla ()
983+ # Don't clear during __init__ because they're already been cleared by
984+ # their own __init__.
985+ if not self ._in_init :
986+ self .xaxis .cla ()
987+ self .yaxis .cla ()
988+ for name , spine in six .iteritems (self .spines ):
989+ spine .cla ()
984990
985991 self .ignore_existing_data_limits = True
986992 self .callbacks = cbook .CallbackRegistry ()
0 commit comments