Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6dbcaf1

Browse files
committed
Don't clear Spines and Axis twice in Axes.__init__.
Both these classes have called their own .cla() method in their .__init__() method, so don't call it again in Axes.cla() if doing Axes.__init__().
1 parent 94ed61c commit 6dbcaf1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ def __init__(self, fig, rect,
479479
""" % {'scale': ' | '.join(
480480
[repr(x) for x in mscale.get_scale_names()])}
481481
martist.Artist.__init__(self)
482+
self._in_init = True
482483
if isinstance(rect, mtransforms.Bbox):
483484
self._position = rect
484485
else:
@@ -576,6 +577,8 @@ def __init__(self, fig, rect,
576577
right=rcParams['ytick.right'] and rcParams['ytick.major.right'],
577578
which='major')
578579

580+
self._in_init = False
581+
579582
def __getstate__(self):
580583
# The renderer should be re-created by the figure, and then cached at
581584
# that point.
@@ -965,10 +968,13 @@ def cla(self):
965968
xaxis_visible = self.xaxis.get_visible()
966969
yaxis_visible = self.yaxis.get_visible()
967970

968-
self.xaxis.cla()
969-
self.yaxis.cla()
970-
for name, spine in six.iteritems(self.spines):
971-
spine.cla()
971+
# Don't clear during __init__ because they're already been cleared by
972+
# their own __init__.
973+
if not self._in_init:
974+
self.xaxis.cla()
975+
self.yaxis.cla()
976+
for name, spine in six.iteritems(self.spines):
977+
spine.cla()
972978

973979
self.ignore_existing_data_limits = True
974980
self.callbacks = cbook.CallbackRegistry()

0 commit comments

Comments
 (0)