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

Skip to content

Commit 6233726

Browse files
committed
ENH: make it work with axes objects not strings
Update the objects in place
1 parent a2d4d9a commit 6233726

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/figure.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ def _process_layout(layout):
16221622
nested = {}
16231623
for j, row in enumerate(layout):
16241624
for k, v in enumerate(row):
1625-
if isinstance(v, str):
1625+
if isinstance(v, (str, Axes)):
16261626
unique_ids.add(v)
16271627
else:
16281628
nested[(j, k)] = v
@@ -1641,7 +1641,13 @@ def _do_layout(gs, layout, unique_ids, nested):
16411641
if not np.all(covered[slc] == False):
16421642
raise ValueError
16431643
covered[slc] = True
1644-
output[name] = self.add_subplot(gs[slc], **subplot_kw)
1644+
if isinstance(name, str):
1645+
output[name] = self.add_subplot(gs[slc], **subplot_kw)
1646+
else:
1647+
ax = name
1648+
ax.set_subplotspec(gs[slc])
1649+
ax.update_params()
1650+
ax.set_position(ax.figbox)
16451651

16461652
for (j, k), layout in nested.items():
16471653
layout = np.asarray(layout)

0 commit comments

Comments
 (0)