8000 Allow "figure" kwarg for host functions in parasite_axes. · matplotlib/matplotlib@b9ed974 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9ed974

Browse files
author
none
committed
Allow "figure" kwarg for host functions in parasite_axes.
1 parent 2c95107 commit b9ed974

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,10 @@ def host_axes(*args, **kwargs):
487487
import matplotlib.pyplot as plt
488488
axes_class = kwargs.pop("axes_class", None)
489489
host_axes_class = host_axes_class_factory(axes_class)
490-
fig = plt.gcf()
490+
if "figure" in kwargs:
491+
fig = kwargs["figure"]
492+
else:
493+
fig = plt.gcf()
491494
ax = host_axes_class(fig, *args, **kwargs)
492495
fig.add_axes(ax)
493496
plt.draw_if_interactive()
@@ -497,7 +500,10 @@ def host_subplot(*args, **kwargs):
497500
import matplotlib.pyplot as plt
498501
axes_class = kwargs.pop("axes_class", None)
499502
host_subplot_class = host_subplot_class_factory(axes_class)
500-
fig = plt.gcf()
503+
if "figure" in kwargs:
504+
fig = kwargs["figure"]
505+
else:
506+
fig = plt.gcf()
501507
ax = host_subplot_class(fig, *args, **kwargs)
502508
fig.add_subplot(ax)
503509
plt.draw_if_interactive()

0 commit comments

Comments
 (0)
0