gsplot.figure.axes_inset#

Functions

axes_inset(ax,Β bounds[,Β transform,Β ...])

A functional interface to create an inset axis in a Matplotlib figure.

axes_inset_padding(ax,Β width,Β height[,Β loc,Β ...])

A functional interface to create an inset axis with padding in a Matplotlib figure.

axes_inset(ax, bounds, transform=None, projection=None, polar=False, lab_lims=None, minor_ticks=True, zoom=True, zoom_color='black', zoom_alpha=0.3, zorder=5, **kwargs)[source]#

A functional interface to create an inset axis in a Matplotlib figure.

This function wraps the AxesInset class, allowing inset axes to be created with a simpler function-based interface.

Parameters:
  • ax (Axes) – The main axis in the figure.

  • bounds (tuple[float, float, float, float]) – Bounds for the inset axis in the format (x0, y0, width, height).

  • transform (Transform | None, optional) – The transform to apply to the inset axis. Default is None.

  • projection (str | None, optional) – The projection type for the inset axis. Default is None.

  • polar (bool, default False) – If True, the inset axis will use a polar projection.

  • lab_lims (list[Any] | None, optional) – Axis labels and limits for the inset axis.

  • minor_ticks (bool, default True) – Whether to enable minor ticks on the inset axis.

  • zoom (bool or tuple[tuple[int, int], tuple[int, int]], default True) – Zoom settings for the inset axis.

  • zoom_color (ColorType, default 'black') – Color for the zoom connectors and patches.

  • zoom_alpha (int | float, default 0.3) – Transparency for the zoom connectors and patches.

  • zorder (int | float, default 5) – The z-order of the inset axis.

  • **kwargs (Any) – Additional keyword arguments for label configuration or other customizations.

Returns:

axins – The created inset axis.

Return type:

Axes

Notes

zoom provides manual inset zooming when a tuple is provided. zoom = ((1, 2), (3, 4)) will connect the main axis to the inset axis as follows:

  • 1 (main) - 2 (inset)

  • 3 (main) - 3 (inset)

The indices represent the corners of the axes, with 1 being the bottom left corner

Examples

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> axins = axes_inset(ax, [0.5, 0.5, 0.4, 0.4], lab_lims=["X", "Y", 0, 1, 0, 1])
>>> axins.plot([0, 1], [0, 1])
axes_inset_padding(ax, width, height, loc='upper right', borderpad=0.5, bbox_to_anchor=None, bbox_transform=None, axes_kwargs=None, lab_lims=None, minor_ticks=True, zoom=True, zoom_color='black', zoom_alpha=0.3, **kwargs)[source]#

A functional interface to create an inset axis with padding in a Matplotlib figure.

This function wraps the AxesInsetPadding class, allowing inset axes to be created with a simpler function-based interface.

Parameters:
  • ax (Axes) – The parent axis where the inset axis will be placed.

  • width (str or float) – The width of the inset axis.

  • height (str or float) – The height of the inset axis.

  • loc (str, default "upper right") – The location of the inset axis relative to the parent axis.

  • borderpad (float, default 0.5) – Padding between the parent axis and the inset axis.

  • bbox_to_anchor (tuple[float, float] | BboxBase | None, optional) – Bounding box to anchor the inset axis.

  • bbox_transform (Transform | None, optional) – Transformation for the bounding box anchor.

  • axes_kwargs (dict[str, Any] | None, optional) – Additional keyword arguments for the inset axis creation.

  • lab_lims (list[Any] | None, optional) – Axis labels and limits for the inset axis.

  • minor_ticks (bool, default True) – Whether to enable minor ticks on the inset axis.

  • zoom (bool or tuple[tuple[int, int], tuple[int, int]], default True) – Zoom settings for the inset axis.

  • zoom_color (ColorType, default "black") – Color for the zoom connectors and patches.

  • zoom_alpha (int | float, default 0.3) – Transparency for the zoom connectors and patches.

  • **kwargs (Any) – Additional keyword arguments for label configuration or other customizations.

Returns:

axins – The created inset axis.

Return type:

Axes

Notes

zoom provides manual inset zooming when a tuple is provided. zoom = ((1, 2), (3, 4)) will connect the main axis to the inset axis as follows:

  • 1 (main) - 2 (inset)

  • 3 (main) - 3 (inset)

The indices represent the corners of the axes, with 1 being the bottom left corner

Examples

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> axins = axes_inset_padding(ax, "30%", "30%", loc="upper right", zoom=False)
>>> axins.plot([0, 1], [0, 1])