XarraySubplotTitlesInferer

class PlasmaCalcs.plotting.labels.XarraySubplotTitlesInferer(array, t=None, *, row=None, col=None, **kw_super)

Bases: PlotSettingsMixin

infers base titles & suptitle to use for subplots.

“Base” means before title.format(nondim coord values from the array)
array: xarray.DataArray
infer titles from this array, after filling any missing coords
(e.g. if dim_1 has no coords, use np.range(dim_1.size))
t: None or str
dimension name for the time axis (for movies).
row: None or str
dimension to plot ACROSS rows.
None –> not plotting anything across rows; ncols=1.
col: None or str
dimension to plot DOWN columns.
None –> not plotting anything across columns; nrows=1.
subplot_title_width: UNSET, None, or number (default: UNSET)
suggested width [number of characters] for subplot titles;
default title routines might make multiline title if title would be longer than this.
UNSET –> use DEFAULTS.PLOT.SUBPLOT_TITLE_WIDTH (default: 20).
None –> no maximum width.
suptitle_width: UNSET, None, or number (default: UNSET)
suggested width [number of characters] for suptitle;
default routines might make multiline suptitle to avoid going longer than this.
UNSET –> use DEFAULTS.PLOT.SUPTITLE_WIDTH (default: 40).
None –> no maximum width.
To view or adjust plot settings in self, see self.plot_settings, or help(self.plot_settings).

Methods

__init_subclass__(*args_super, **kw)

appends note about using self.plot_settings, to cls.__doc__.

infer_suptitle()

infers title to use for subplots.

infer_title()

infers title to use for subplots.

title_from_coords([cnames, width, formattable])

return a decent title from scalar coords.

classmethod __init_subclass__(*args_super, **kw)

appends note about using self.plot_settings, to cls.__doc__.

if “PlotSettings” or “plot_settings” appears in cls.__doc__, do NOT append this note;
assuming instead that this means the doc already mentions how to use plot_settings.
infer_suptitle()

infers title to use for subplots.

This may include the array name, units, t dim,
and any scalar xarray_nondim_coords not associated with row or col.
formatting will be nice depending on which pieces of info exist.
name –> ‘{name} {units}n{t}n{nondim_coords}’
no name –> ‘{t} {units}n{nondim_coords}’
no t –> ‘{nondim_coords} {units}’
if no units info remove {units} part
if no scalar nondim_coords_values remove n{nondim_coords} part
infer_title()

infers title to use for subplots.

This will just include the row & col dims & any associated coords.
(excluding coords which will still be multidimensional within each subplot.)
(also excluding MultiIndex coords; they are ugly, and all their info
is already in title, via the coords within the MultiIndex.)
title_from_coords(cnames=None, *, width=None, formattable=True)

return a decent title from scalar coords.

cnames: None or list of str
coords to include values of in the title.
None –> include all scalar coords.
width: None or int
max number of characters per line, before putting a newline between coords.
formattable: bool
whether to return a formattable version of the title.