Skip to content

Figure mpl

subsurfaceio.plot.figure_mpl

Matplotlib backend for express plot specifications.

Classes:

Name Description
MplFigure

Renders a plot specification with matplotlib, via matplotlib-express.

Attributes:

Name Type Description
AxisSharing TypeAlias

Facet axis sharing, as accepted by matplotlib.pyplot.subplots.

AxisSharing module-attribute

AxisSharing: TypeAlias = (
    bool | Literal["all", "row", "col", "none"]
)

Facet axis sharing, as accepted by matplotlib.pyplot.subplots.

True is equivalent to 'all' and False to 'none'. Wider than the Plotly backend, which takes a plain boolean.

MplFigure pydantic-model

Bases: BaseFigure

Renders a plot specification with matplotlib, via matplotlib-express.

Styling from STYLE_RC is applied for the duration of plot.

Figures are created through pyplot, which keeps a global reference to every one of them. In a long-lived process, call close when finished, or use the figure as a context manager. Figures are deliberately not closed automatically, because notebook inline display relies on that same global registry.

Attributes:

Name Type Description
sharex AxisSharing

Facet x-axis sharing, accepting matplotlib's string forms.

sharey AxisSharing

Facet y-axis sharing, accepting matplotlib's string forms.

Fields:

fig property

fig: Figure

Rendered matplotlib figure.

Raises:

Type Description
RuntimeError

When accessed before plot.

sharex pydantic-field

sharex: AxisSharing = True

sharey pydantic-field

sharey: AxisSharing = True

close

close() -> None

Release the figure from the pyplot registry.

The figure object stays usable for saving afterward, but is no longer reachable through pyplot and no longer displays inline in notebooks. Idempotent, and a no-op before plot.

set_minor_ticks

set_minor_ticks() -> Self

Add automatic minor ticks to every linear axis.

Returns:

Type Description
Self

Self, for chaining.