@@ -481,6 +481,7 @@ def __init__(self, fig, rect,
481
481
""" % {'scale' : ' | ' .join (
482
482
[repr (x ) for x in mscale .get_scale_names ()])}
483
483
martist .Artist .__init__ (self )
484
+ self ._in_init = True
484
485
if isinstance (rect , mtransforms .Bbox ):
485
486
self ._position = rect
486
487
else :
@@ -578,6 +579,8 @@ def __init__(self, fig, rect,
578
579
right = rcParams ['ytick.right' ] and rcParams ['ytick.major.right' ],
579
580
which = 'major' )
580
581
582
+ self ._in_init = False
583
+
581
584
def __getstate__ (self ):
582
585
# The renderer should be re-created by the figure, and then cached at
583
586
# that point.
@@ -609,11 +612,11 @@ def get_window_extent(self, *args, **kwargs):
609
612
def _init_axis (self ):
610
613
"move this out of __init__ because non-separable axes don't use it"
611
614
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 )
614
617
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 )
617
620
self ._update_transScale ()
618
621
619
622
def set_figure (self , fig ):
@@ -977,10 +980,13 @@ def cla(self):
977
980
xaxis_visible = self .xaxis .get_visible ()
978
981
yaxis_visible = self .yaxis .get_visible ()
979
982
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 ()
984
990
985
991
self .ignore_existing_data_limits = True
986
992
self .callbacks = cbook .CallbackRegistry ()
0 commit comments