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

Skip to content

Commit f49e48f

Browse files
committed
FIX: make local axes a stack
1 parent d591875 commit f49e48f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/matplotlib/figure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def __init__(self):
250250
self.figure = self
251251
# list of child gridspecs for this figure
252252
self._gridspecs = []
253-
self._localaxes = [] # keep track of axes at this level
253+
self._localaxes = _AxesStack() # keep track of axes at this level
254254
self.artists = []
255255
self.lines = []
256256
self.patches = []
@@ -276,7 +276,7 @@ def _get_draw_artists(self, renderer):
276276
artists = sorted(
277277
(artist for artist in artists if not artist.get_animated()),
278278
key=lambda artist: artist.get_zorder())
279-
for ax in self._localaxes:
279+
for ax in self._localaxes.as_list():
280280
locator = ax.get_axes_locator()
281281
if locator:
282282
pos = locator(ax, renderer)
@@ -345,7 +345,7 @@ def get_children(self):
345345
"""Get a list of artists contained in the figure."""
346346
return [self.patch,
347347
*self.artists,
348-
*self._localaxes,
348+
*self._localaxes.as_list(),
349349
*self.lines,
350350
*self.patches,
351351
*self.texts,
@@ -836,7 +836,7 @@ def add_subplot(self, *args, **kwargs):
836836
def _add_axes_internal(self, key, ax):
837837
"""Private helper for `add_axes` and `add_subplot`."""
838838
self._axstack.add(key, ax)
839-
self._localaxes += [ax]
839+
self._localaxes.add(key, ax)
840840
self.sca(ax)
841841
ax._remove_method = self.delaxes
842842
self.stale = True
@@ -2020,7 +2020,7 @@ def get_axes(self):
20202020
Return a list of axes in the SubPanel. You can access and modify the
20212021
axes in the Figure through this list.
20222022
"""
2023-
return self._localaxes
2023+
return self._localaxes.as_list()
20242024

20252025
axes = property(get_axes, doc="""
20262026
List of axes in the Figure. You can access and modify the axes

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135
# Calculate the pseudo-data width and height
136136
pseudo_bbox = self.transLimits.inverted().transform([(0, 0), (1, 1)])
137137
self._pseudo_w, self._pseudo_h = pseudo_bbox[1] - pseudo_bbox[0]
138-
138+
139139
# mplot3d currently manages its own spines and needs these turned off
140140
# for bounding box calculations
141141
for k in self.spines.keys():

0 commit comments

Comments
 (0)