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

Skip to content

Commit 874fe77

Browse files
Lazily construct sticky edges
1 parent 5bbd7a1 commit 874fe77

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

lib/matplotlib/artist.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def __init__(self):
223223
self._snap = None
224224
self._sketch = mpl.rcParams['path.sketch']
225225
self._path_effects = mpl.rcParams['path.effects']
226-
self._sticky_edges = _XYPair([], [])
226+
self._sticky_edges = None
227227
self._in_layout = True
228228

229229
def __getstate__(self):
@@ -1209,6 +1209,8 @@ def sticky_edges(self):
12091209
>>> artist.sticky_edges.y[:] = (ymin, ymax)
12101210
12111211
"""
1212+
if self._sticky_edges is None:
1213+
self._sticky_edges = _XYPair([], [])
12121214
return self._sticky_edges
12131215

12141216
def update_from(self, other):
@@ -1223,8 +1225,11 @@ def update_from(self, other):
12231225
self._label = other._label
12241226
self._sketch = other._sketch
12251227
self._path_effects = other._path_effects
1226-
self.sticky_edges.x[:] = other.sticky_edges.x.copy()
1227-
self.sticky_edges.y[:] = other.sticky_edges.y.copy()
1228+
if other._sticky_edges is not None:
1229+
self.sticky_edges.x[:] = other._sticky_edges.x.copy()
1230+
self.sticky_edges.y[:] = other._sticky_edges.y.copy()
1231+
else:
1232+
self._sticky_edges = None
12281233
self.pchanged()
12291234
self.stale = True
12301235

lib/matplotlib/axes/_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,9 +3033,6 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
30333033
x_stickies = y_stickies = np.array([])
30343034
if self.use_sticky_edges:
30353035
if self._xmargin and scalex and self.get_autoscalex_on():
3036-
# Use ._children and ._sticky_edges directly, because the extra
3037-
# artists in .get_children() (spines, axes, titles, etc.) never
3038-
# have sticky edges, so we can skip them for performance.
30393036
x_sticky_lists = []
30403037
for ax in x_shared:
30413038
for artist in ax.get_children():

0 commit comments

Comments
 (0)