uvex_transients.utils.plotting.resolve_fig_axes#

uvex_transients.utils.plotting.resolve_fig_axes(fig: Figure | None = None, axes: Axes | None = None, fig_size: tuple | None = None, dpi: float | None = None, subplot_kw: dict | None = None) → tuple[Figure, Axes][source]#

Resolve a (figure, axes) pair from any combination of already-provided pieces.

Every plotting function in the package takes optional fig/axes arguments and starts by calling this, so callers can either let a function create its own figure or hand it axes already embedded in a larger layout (e.g. one panel of a ~matplotlib.pyplot.subplots grid), without the function needing its own branching for the two cases.

Parameters:
  • fig (matplotlib.figure.Figure, optional) – An existing figure. If None, one is created (unless axes is given, in which case its parent figure is used).

  • axes (matplotlib.axes.Axes, optional) – Existing axes to draw onto. If None, new axes are created on fig.

  • fig_size (tuple, optional) – (width, height) in inches for a newly created figure, forwarded to ~matplotlib.pyplot.subplots. Defaults to config["plotting.default_figsize"].

  • dpi (float, optional) – Resolution for a newly created figure, forwarded to ~matplotlib.pyplot.subplots. Defaults to config["plotting.dpi"] (the same default set_plot_style applies globally via rcParams["figure.dpi"]); pass explicitly to override it for one figure, e.g. a higher-resolution figure meant to be saved as a small thumbnail.

  • subplot_kw (dict, optional) – Forwarded to ~matplotlib.pyplot.subplots when new axes are created, e.g. {"projection": "aitoff"}. Ignored when axes is already given.

Returns: