gsplot.inset#

inset(parent, bounds, *, label=None, zoom=False, style='paper', zorder=5, zoom_zorder=None)#

Create a publication-styled inset on an explicit parent Axes.

Parameters:
  • parent (Axes) – Matplotlib Axes that owns the child and optional zoom indicator.

  • bounds (tuple[float, float, float, float] | InsetSpec) – Normalized (left, bottom, width, height) parent-Axes fractions, or an advanced gsplot.InsetSpec placement.

  • label (tuple[str, str] | tuple[str, str, Any, Any] | Sequence[Any] | None) – Optional (xlabel, ylabel) or (xlabel, ylabel, xlim, ylim) record. Label padding is zero points.

  • zoom (bool | tuple[tuple[int, int], tuple[int, int]]) – False for no indicator, True for Matplotlib’s automatic indicator, or exactly two (parent_corner, inset_corner) pairs. Corner identifiers are 1 upper-right, 2 upper-left, 3 lower-left, and 4 lower-right.

  • style (Literal['paper'] | None) – Apply the target-local "paper" profile by default, or use None to retain ambient Matplotlib styling.

  • zorder (float) – Finite child Axes z-order, defaulting to 5.

  • zoom_zorder (float | None) – Optional finite indicator z-order. The default is zorder - 0.01 and is valid only when zoom is enabled.

Returns:

Newly created native child Axes.

Return type:

matplotlib.axes.Axes

Raises:

LayoutError – If the parent, placement, label, zoom controls, style, or z-orders are invalid, or Matplotlib cannot create the requested inset.

Notes

Every option is validated before child creation. Indicator artists belong to the parent Axes and track the child’s limits. This function does not run a Figure layout engine or change global Matplotlib state.

Examples

>>> import gsplot as gs
>>> figure, ax = gs.subplots()
>>> child = gs.inset(ax, (0.6, 0.6, 0.3, 0.3), label=("x", "y"))
>>> child.figure is figure
True
>>> figure.clear()