crested.pl.create_plot#
- crested.pl.create_plot(ax, kwargs_dict, default_width=8, default_height=8, default_sharex=False, default_sharey=False, nrows=1, ncols=1, default_layout='constrained', default_h_pad=0.1, default_w_pad=0.1, **kwargs)#
Create a new plot or gather the figure if already existing.
Effectively a wrapper around
plt.subplotsif there’s no pre-existing axis, and a way to get the Figure object if there is.Note
This function should never be called directly. Rather, the other plotting functions call this function.
- Parameters:
ax (plt.Axes | None) – A single axis object, or None. If an axis, will return its associated figure. If None, will create a new figure according to the other parameters.
kwargs_dict (dict) – The dictionary containing kwargs to set figure properties. Will consume arguments ‘width’, ‘height’, ‘sharex’, ‘sharey’.
default_width (int (default:
8)) – The default width of the figure, forplt.subplots(figsize), if not inkwargs_dict.default_height (int (default:
8)) – The default height of the figure, forplt.subplots(figsize), if not inkwargs_dict.default_sharex (bool (default:
False)) – Default state ofplt.subplots(sharex)if not inkwargs_dict.default_sharey (bool (default:
False)) – Default state ofplt.subplots(sharey)if not inkwargs_dict.nrows (int (default:
1)) – The number of rows for the subplot grid.ncols (int (default:
1)) – The number of columns for the subplot grid.default_layout (Literal[‘constrained’, ‘compressed’, ‘tight’, None] (default:
'constrained')) – The layout engine to use, if not inkwargs_dict. Seefigure()for more information.default_h_pad (float | None (default:
0.1)) – Minimum height padding to use between subplots, in inches, if not inkwargs_dict. Seeset()for more information.default_w_pad (float | None (default:
0.1)) – Minimum width padding to use between subplots, in inches, if not inkwargs_dict. Seeset()for more information.kwargs – Extra kwargs passed to
plt.subplots.
- Return type:
(plt.Figure, plt.Axes) | (plt.Figure, list[plt.Axes])