diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 7948c14de8e9..6f0839eaf851 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -479,6 +479,7 @@ def __init__(self, fig, rect, """ % {'scale': ' | '.join( [repr(x) for x in mscale.get_scale_names()])} martist.Artist.__init__(self) + self._in_init = True if isinstance(rect, mtransforms.Bbox): self._position = rect else: @@ -576,6 +577,8 @@ def __init__(self, fig, rect, right=rcParams['ytick.right'] and rcParams['ytick.major.right'], which='major') + self._in_init = False + def __getstate__(self): # The renderer should be re-created by the figure, and then cached at # that point. @@ -607,11 +610,11 @@ def get_window_extent(self, *args, **kwargs): def _init_axis(self): "move this out of __init__ because non-separable axes don't use it" self.xaxis = maxis.XAxis(self) - self.spines['bottom'].register_axis(self.xaxis) - self.spines['top'].register_axis(self.xaxis) + self.spines['bottom'].register_axis(self.xaxis, _init=True) + self.spines['top'].register_axis(self.xaxis, _init=True) self.yaxis = maxis.YAxis(self) - self.spines['left'].register_axis(self.yaxis) - self.spines['right'].register_axis(self.yaxis) + self.spines['left'].register_axis(self.yaxis, _init=True) + self.spines['right'].register_axis(self.yaxis, _init=True) self._update_transScale() def set_figure(self, fig): @@ -965,10 +968,13 @@ def cla(self): xaxis_visible = self.xaxis.get_visible() yaxis_visible = self.yaxis.get_visible() - self.xaxis.cla() - self.yaxis.cla() - for name, spine in six.iteritems(self.spines): - spine.cla() + # Don't clear during __init__ because they're already been cleared by + # their own __init__. + if not self._in_init: + self.xaxis.cla() + self.yaxis.cla() + for name, spine in six.iteritems(self.spines): + spine.cla() self.ignore_existing_data_limits = True self.callbacks = cbook.CallbackRegistry() diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index a5d2b03c34b5..9976dfbe0c6b 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -245,8 +245,10 @@ def __init__(self, *args, **kwargs): If you need to interpolate data points, consider running cbook.simple_linear_interpolation on the data before passing to matplotlib.""") Axes.__init__(self, *args, **kwargs) + self._in_init = True self.set_aspect('equal', adjustable='box', anchor='C') self.cla() + self._in_init = False __init__.__doc__ = Axes.__init__.__doc__ def cla(self): diff --git a/lib/matplotlib/spines.py b/lib/matplotlib/spines.py index c6b04fe43dba..1026c7c3a518 100644 --- a/lib/matplotlib/spines.py +++ b/lib/matplotlib/spines.py @@ -151,7 +151,7 @@ def _ensure_position_is_set(self): self._position = ('outward', 0.0) # in points self.set_position(self._position) - def register_axis(self, axis): + def register_axis(self, axis, _init=False): """register an axis An axis should be registered with its corresponding spine from @@ -159,7 +159,9 @@ def register_axis(self, axis): properties when needed. """ self.axis = axis - if self.axis is not None: + if not _init and self.axis is not None: + # Clear the axis when added, but *not* if the caller says it was + # just created. self.axis.cla() self.stale = True pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy