@@ -460,20 +460,48 @@ def host_subplot_class_factory(axes_class):
460460
461461
462462def host_axes (* args , ** kwargs ):
463+ """
464+ Create axes that can act as a hosts to parasitic axes.
465+
466+ Parameters
467+ ----------
468+ figure : `matplotlib.figure.Figure`
469+ Figure to which the axes will be added. Defaults to the current figure
470+ `pyplot.gcf()`.
471+
472+ *args, **kwargs :
473+ Will be passed on to the underlying ``Axes`` object creation.
474+ """
463475 import matplotlib .pyplot as plt
464476 axes_class = kwargs .pop ("axes_class" , None )
465477 host_axes_class = host_axes_class_factory (axes_class )
466- fig = plt .gcf ()
478+ fig = kwargs .get ("figure" , None )
479+ if fig is None :
480+ fig = plt .gcf ()
467481 ax = host_axes_class (fig , * args , ** kwargs )
468482 fig .add_axes (ax )
469483 plt .draw_if_interactive ()
470484 return ax
471485
472486def host_subplot (* args , ** kwargs ):
487+ """
488+ Create a subplot that can act as a host to parasitic axes.
489+
490+ Parameters
491+ ----------
492+ figure : `matplotlib.figure.Figure`
493+ Figure to which the subplot will be added. Defaults to the current
494+ figure `pyplot.gcf()`.
495+
496+ *args, **kwargs :
497+ Will be passed on to the underlying ``Axes`` object creation.
498+ """
473499 import matplotlib .pyplot as plt
474500 axes_class = kwargs .pop ("axes_class" , None )
475501 host_subplot_class = host_subplot_class_factory (axes_class )
476- fig = plt .gcf ()
502+ fig = kwargs .get ("figure" , None )
503+ if fig is None :
504+ fig = plt .gcf ()
477505 ax = host_subplot_class (fig , * args , ** kwargs )
478506 fig .add_subplot (ax )
479507 plt .draw_if_interactive ()
0 commit comments