Skip to content

Commit 808a9e7

Browse files
author
Cyril Gadal
committed
Changes to SubFigures so it behave like a regular artist:
- changing self._get_draw_artists() so subfigs are now part of the artists list. - changing draw() methods so subfigs are drawn like regular artists
1 parent dceb278 commit 808a9e7

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/matplotlib/figure.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class FigureBase(Artist):
120120
Base class for `.Figure` and `.SubFigure` containing the methods that add
121121
artists to the figure or subfigure, create Axes, etc.
122122
"""
123+
123124
def __init__(self, **kwargs):
124125
super().__init__()
125126
# remove the non-figure artist _axes property
@@ -152,12 +153,12 @@ def __init__(self, **kwargs):
152153
def _get_draw_artists(self, renderer):
153154
"""Also runs apply_aspect"""
154155
artists = self.get_children()
155-
for sfig in self.subfigs:
156-
artists.remove(sfig)
157-
childa = sfig.get_children()
158-
for child in childa:
159-
if child in artists:
160-
artists.remove(child)
156+
# for sfig in self.subfigs:
157+
# artists.remove(sfig)
158+
# childa = sfig.get_children()
159+
# for child in childa:
160+
# if child in artists:
161+
# artists.remove(child)
161162

162163
artists.remove(self.patch)
163164
artists = sorted(
@@ -2294,8 +2295,7 @@ def draw(self, renderer):
22942295
self.patch.draw(renderer)
22952296
mimage._draw_list_compositing_images(
22962297
renderer, self, artists, self.figure.suppressComposite)
2297-
for sfig in self.subfigs:
2298-
sfig.draw(renderer)
2298+
22992299
renderer.close_group('subfigure')
23002300

23012301
finally:
@@ -2782,8 +2782,8 @@ def set_constrained_layout(self, constrained):
27822782
self.stale = True
27832783

27842784
@_api.deprecated(
2785-
"3.6", alternative="figure.get_layout_engine().set()",
2786-
pending=True)
2785+
"3.6", alternative="figure.get_layout_engine().set()",
2786+
pending=True)
27872787
def set_constrained_layout_pads(self, **kwargs):
27882788
"""
27892789
Set padding for ``constrained_layout``.
@@ -3101,9 +3101,6 @@ def draw(self, renderer):
31013101
mimage._draw_list_compositing_images(
31023102
renderer, self, artists, self.suppressComposite)
31033103

3104-
for sfig in self.subfigs:
3105-
sfig.draw(renderer)
3106-
31073104
renderer.close_group('figure')
31083105
finally:
31093106
self.stale = False

0 commit comments

Comments
 (0)