majordome.plotting#

class majordome.plotting.MajordomePlot(shape: tuple[int, int], style: str = 'classic', opts: dict[str, Any] = {}, size: tuple[float, float] | None = None, xlabel: str | list[str] | None = None, ylabel: str | list[str] | None = None)#

Handles the creation and management of plots.

Provides a handle for creating and managing plots using Matplotlib. It is aimed at standardizing the plot creation process across the Majordome framework.

Parameters:
shapetuple[int, int]

Shape of the plot as (n_rows, n_cols).

stylestr, optional

Matplotlib style to use for the plot. By default “classic”.

optsdict[str, Any], optional

Additional options to pass to plt.subplots(), by default {}.

sizetuple[float, float] | None, optional

Size of the plot in inches as (width, height). If None, the default size will be used. By default None.

xlabelstr | list[str] | None, optional

Label(s) for the x-axis. If a list is provided, each subplot will get its own label. By default None.

ylabelstr | list[str] | None, optional

Label(s) for the y-axis. If a list is provided, each subplot will get its own label. By default None.

property axes: list[Axes]#

Provides access to underlying axes.

property figure: Figure#

Provides access to undelining figure.

get_label(name: str, k: int) str#

Get label for axis at the k-th subplot, if any.

classmethod new(_func: Callable[[Params], None] | None = None, *, shape: tuple[int, int] = (1, 1), style: str = 'classic', sharex: bool = True, facecolor: str = 'white', grid: bool = True, size: tuple[float, float] | None = None, xlabel: str | list[str] | None = None, ylabel: str | list[str] | None = None) Callable[[Callable[[Params], None]], Any]#

Wraps a function for ensuring a standardized plot.

resize(w: float, h: float) None#

Resize a plot with width and height in inches.

savefig(filename: str | Path, **kwargs) None#

Wrapper for saving a figure to file.

subplots() tuple[Figure, list[Axes]]#

Provides access to underlying figure and axes.

majordome.plotting.centered_colormap(name: str, vmin: float, vmax: float, vcenter: float = 0.0) LookupTable#

Ensure the center of a colormap is at zero.

Parameters:
namestr

Name of the colormap to use.

vminfloat

Minimum value of the data range.

vmaxfloat

Maximum value of the data range.

vcenterfloat, optional

Center value of the colormap, by default 0.

Returns:
LookupTable

A PyVista LookupTable with the centered colormap.