@@ -460,20 +460,48 @@ def host_subplot_class_factory(axes_class):
460
460
461
461
462
462
def 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
+ """
463
475
import matplotlib .pyplot as plt
464
476
axes_class = kwargs .pop ("axes_class" , None )
465
477
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 ()
467
481
ax = host_axes_class (fig , * args , ** kwargs )
468
482
fig .add_axes (ax )
469
483
plt .draw_if_interactive ()
470
484
return ax
471
485
472
486
def 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
+ """
473
499
import matplotlib .pyplot as plt
474
500
axes_class = kwargs .pop ("axes_class" , None )
475
501
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 ()
477
505
ax = host_subplot_class (fig , * args , ** kwargs )
478
506
fig .add_subplot (ax )
479
507
plt .draw_if_interactive ()
0 commit comments