Skip to content

plot.serialization_matplotlib

Serialization of Figure object to matplotlib.

MatplotlibFigureSerializer

Serializer for figures to matplotlib.

to_figure classmethod

to_figure(experiment, figure, settings=None)

Convert sbmlsim.Figure to matplotlib figure.

Parameters:

Name Type Description Default
experiment Any

the experiment the data of the figure is read from, whose figure_settings override the settings of the run.

required
figure Figure

the figure.

required
settings FigureSettings | Mapping[str, Any] | None

the settings of the run, a FigureSettings or overrides of the defaults, which the settings of the experiment and of the figure override, see Figure.resolved_settings.

None

Returns:

Type Description
Figure

The matplotlib figure.

saved_box

saved_box(fig)

Get the box of a figure to save, bbox_inches of savefig.

bbox_inches="tight" draws the whole figure to find the ticks, labels, legends and titles which reach beyond it, and once more to write it, 15 % of the time of the simulation experiments of a model. A figure which the serializer built has its texts measured already and needs no drawing for its box: the tight box of its artists, measured with _measuring_renderer and padded by savefig.pad_inches, is the box of "tight" up to the metrics of the fonts of the format (a fraction of a point). Any other figure, and one with a layout engine, which lays it out when it is drawn, is saved "tight".

Parameters:

Name Type Description Default
fig Figure

the figure.

required

Returns:

Type Description
Bbox | Literal['tight']

The box in inches, or "tight".

limit_log_axis

limit_log_axis(ax, axis='y', low=None, high=None)

Limit a log axis of matplotlib to LOG_DECADES below its largest value.

The limits of the data drawn so far, see sbmlsim.plot.plotting.log_limits; for a figure of a model drawn with matplotlib itself, after its data and set_yscale("log").

Parameters:

Name Type Description Default
ax Axes

the axes.

required
axis str

"x" or "y".

'y'
low float | None

the lower limit set on the axis, None without.

None
high float | None

the upper limit set on the axis, None without.

None

limit_log_axes

limit_log_axes(figure)

Limit every automatic log axis of a figure, see limit_log_axis.

The custom figures of an experiment (figures_mpl) are drawn by the model; a log axis whose limits it set itself (autoscale off) is kept.