Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions lib/mpl_toolkits/axes_grid1/parasite_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,48 @@ def host_subplot_class_factory(axes_class):


def host_axes(*args, **kwargs):
"""
Create axes that can act as a hosts to parasitic axes.

Parameters
----------
figure : `matplotlib.figure.Figure`
Figure to which the axes will be added. Defaults to the current figure
`pyplot.gcf()`.

*args, **kwargs :
Will be passed on to the underlying ``Axes`` object creation.
"""
import matplotlib.pyplot as plt
axes_class = kwargs.pop("axes_class", None)
host_axes_class = host_axes_class_factory(axes_class)
fig = plt.gcf()
fig = kwargs.get("figure", None)
if fig is None:
fig = plt.gcf()
ax = host_axes_class(fig, *args, **kwargs)
fig.add_axes(ax)
plt.draw_if_interactive()
return ax

def host_subplot(*args, **kwargs):
"""
Create a subplot that can act as a host to parasitic axes.

Parameters
----------
figure : `matplotlib.figure.Figure`
Figure to which the subplot will be added. Defaults to the current
figure `pyplot.gcf()`.

*args, **kwargs :
Will be passed on to the underlying ``Axes`` object creation.
"""
import matplotlib.pyplot as plt
axes_class = kwargs.pop("axes_class", None)
host_subplot_class = host_subplot_class_factory(axes_class)
fig = plt.gcf()
fig = kwargs.get("figure", None)
if fig is None:
fig = plt.gcf()
ax = host_subplot_class(fig, *args, **kwargs)
fig.add_subplot(ax)
plt.draw_if_interactive()
Expand Down