Skip to content

plot.points

The lines of a curve over the points of the dimensions of a scan.

A curve names the dimensions of its data it draws one line per point of (over); after broadcasting by name its data must leave at most one more dimension, the axis a line is drawn along: the time of a timecourse, the points of a ragged result, the rows of a dataset or the dimension of the values a scan sets (a value per simulation over a dimension). The lines are in the order of the labels of the over dimensions, the last one fastest. Their colours follow the first over dimension, their line styles the second; a legend entry names its point by the value and unit of the target its dimension changes, else by its label. Everything of a point is found by its label in the dimension, so a curve of selected points (Data(sel=...)) names and colours the points it draws. The colour of a point is the colour map at its value, through the norm of the colour bar (logarithmic for positive values spanning more than a factor of LOG_RATIO); a dimension which does not change one target is coloured by position, with the labels on a discrete colour bar. A band reduces a dimension of draws to two quantiles and the median, computed when the figure is drawn; the draws of a ragged result, whose simulations keep their own time points (the steps of the integrator), are interpolated onto the time points of a figure first, a few hundred which follow the density of their time points (onto_grid, sbmlsim.result.timecourse.plot_times), and its legend entry is its area, <name> (<low>-<high> %).

Line dataclass

Line(point, index, x, y, xerr=None, yerr=None)

One line of a curve, see curve_lines.

Attributes:

Name Type Description
point tuple[Any, ...]

the label of every over dimension, in their order.

index tuple[int, ...]

the position of the point along every over dimension.

x Any

the x values along the axis, without the padding.

y Any

the y values.

xerr Any

the x errors, None without.

yerr Any

the y errors, None without.

BandLine dataclass

BandLine(point, index, x, low, median, high)

One band, see band_lines.

Attributes:

Name Type Description
point tuple[Any, ...]

the label of every over dimension, in their order.

index tuple[int, ...]

the position of the point along every over dimension.

x Any

the x values along the axis.

low Any

the lower quantile.

median Any

the median.

high Any

the upper quantile.

Grids

Grids()

The time points of a figure of the x data of bands, found by their values.

The bands of a figure over the draws mostly share their x, the time of a task with a band per variable of it: the time points and the steps every simulation keeps are found once per x, which was most of the time of the bands (sbmlsim#664). An x is the one of a grid bit for bit, so a band gets the time points of its own values. A figure keeps its grids, see onto_grid.

Start without grids.

of

of(sid, xs, n)

Get the grid of x data, a row per simulation, see onto_grid.

Raises:

Type Description
ValueError

if x of a simulation does not increase.

ColorBarScale dataclass

ColorBarScale(low, high, log, labels, categorical)

The scale of the colour bar of a dimension.

Attributes:

Name Type Description
low float

the value at the low end of the colour bar, the smallest value of the points, the position 0 of a categorical one.

high float

the value at its high end, the largest value of the points, the position n - 1 of a categorical one.

log bool

whether the scale is logarithmic.

labels list[str]

the label of every point of a categorical colour bar, empty for a colour bar of values.

categorical bool

whether it has a band per point, at the positions of the points 0..n-1.

PointStyle dataclass

PointStyle(
    colors,
    linestyles,
    labels,
    colorbar,
    values,
    title,
    scale,
    middle,
)

How the lines of a curve over scan points look, see point_styles.

Attributes:

Name Type Description
colors list[str]

the colour of every point of the first dimension.

linestyles list[str] | None

the line style of every point of the second, None with one.

labels list[list[str]]

the legend label of every point of every dimension.

colorbar bool

whether the first dimension gets a colour bar.

values ndarray

the values of the points of the first dimension, their positions without a single target.

title str

the label of the colour bar, <target> [<unit>] or the dimension.

scale ColorBarScale | None

the scale of the colour bar, None for no points.

middle str

the colour of the middle of the colour range, of the legend entry the lines of a colour bar share.

curve_lines

curve_lines(sid, over, x, y, xerr=None, yerr=None)

Split the data of a curve into one line per point of its over dimensions.

Parameters:

Name Type Description Default
sid str

the id of the curve, for the errors.

required
over Sequence[str]

the dimensions with a line per point, in the order of the lines.

required
x DataArray

the x data.

required
y DataArray

the y data.

required
xerr DataArray | None

the x errors, None without.

None
yerr DataArray | None

the y errors, None without.

None

Returns:

Type Description
list[Line]

The lines, without the padding of a ragged result.

Raises:

Type Description
ValueError

if two arrays have different coordinates of a dimension, an over dimension is not one of the data, or more than one other dimension is left.

band_label

band_label(name, quantiles)

Get the legend label of a band, its name and its quantiles in percent.

Parameters:

Name Type Description Default
name str | None

the name of the band, of a point of it with over; none or empty for a band without a name.

required
quantiles tuple[float, float]

the lower and the upper quantile.

required

Returns:

Type Description
str

<name> (<low>-<high> %), e.g. C (5-95 %), or <low>-<high> %

str

without a name.

nan_quantile

nan_quantile(values, q)

Get a quantile along the last axis, ignoring NaN, vectorized.

The linear interpolation of numpy.nanquantile, whose reduction of an array with a NaN runs in python once per position of the other axes; the values are sorted once (NaN last) and the quantile is taken from the finite values of every position.

Parameters:

Name Type Description Default
values ndarray

the values, reduced along the last axis.

required
q float

the quantile in [0, 1].

required

Returns:

Type Description
ndarray

The quantile of every position of the other axes, NaN where every

ndarray

value is NaN.

nan_quantiles

nan_quantiles(values, qs)

Get quantiles along the last axis, ignoring NaN, the values sorted once.

Every quantile is the one of nan_quantile; the sort, most of its time, is shared by the quantiles, e.g. the two of a band and its median.

Parameters:

Name Type Description Default
values ndarray

the values, reduced along the last axis.

required
qs Sequence[float]

the quantiles in [0, 1].

required

Returns:

Type Description
tuple[ndarray, ...]

Every quantile, see nan_quantile.

onto_grid

onto_grid(sid, x, y, n=PLOT_POINTS, grids=None)

Interpolate the data of a band of a ragged result onto the time points of a figure.

In the ragged layout every simulation keeps its own time points (_point, padded with NaN), so the quantiles of a band at a position of _point would mix times. Every simulation is interpolated linearly onto n time points which follow the density of the time points of all simulations (plot_times), with NaN outside of its own range; the times of the changes, which a simulation has twice (the states before and after it), are among them and give the state after the change, as ScanResult.interpolate does.

Parameters:

Name Type Description Default
sid str

the id of the band, for the errors.

required
x DataArray

the x data, the time over (*dims, _point).

required
y DataArray

the y data over (*dims, _point).

required
n int

the number of time points.

PLOT_POINTS
grids Grids | None

the grids of the x data of the bands of a figure, which the bands of the same x share; one of its own without.

None

Returns:

Type Description
tuple[DataArray, DataArray]

The time points as x over time and the y data over (*dims, time).

Raises:

Type Description
ValueError

if x of a simulation does not increase.

band_lines

band_lines(sid, over, across, quantiles, x, y, grids=None)

Reduce the dimension across of the data of a band to quantiles and the median.

Parameters:

Name Type Description Default
sid str

the id of the band, for the errors.

required
over Sequence[str]

the dimensions with a band per point.

required
across str

the dimension of the draws, which is reduced.

required
quantiles tuple[float, float]

the lower and the upper quantile, in [0, 1].

required
x DataArray

the x data.

required
y DataArray

the y data.

required
grids Grids | None

the grids of the x data of a ragged result, see onto_grid.

None

Returns:

Type Description
list[BandLine]

One band per point of over.

Raises:

Type Description
ValueError

if the data has not the dimension across, or leaves more than one dimension besides over and across; for a ragged result see onto_grid.

point_colors

point_colors(n, color)

Get the colours of the points of a dimension.

Parameters:

Name Type Description Default
n int

the number of points.

required
color str | None

the colour of the style of the curve, None without.

required

Returns:

Type Description
list[str]

Shades of the colour from light to the colour itself, or colours of the

list[str]

colour scale COLORMAP of sbmlsim-core, as hex strings; one point

list[str]

keeps the colour.

point_linestyles

point_linestyles(n)

Get the line styles of the points of a second over dimension.

Raises:

Type Description
ValueError

for more than len(LINE_STYLES) points.

point_values

point_values(dimension, units, labels=None)

Get the target, the values and the unit of a dimension which changes one target.

Parameters:

Name Type Description Default
dimension Dimension | None

the dimension of the scan, None if it is not known.

required
units Mapping[str, str]

the units of the symbols of the model, for values without a unit.

required
labels Sequence[Any] | None

the labels of the points, in their order, every point of the dimension by default; a point is found by its label.

None

Returns:

Type Description
tuple[str, ndarray, str] | None

The target, the values of the points and their unit, None for a

tuple[str, ndarray, str] | None

dimension which changes no or several targets or has not every label.

point_labels

point_labels(dim, labels, dimension, units)

Get the legend label of every point of a dimension.

Parameters:

Name Type Description Default
dim str

the id of the dimension.

required
labels Sequence[Any]

the labels of the points, in their order.

required
dimension Dimension | None

the dimension of the scan, None if it is not known.

required
units Mapping[str, str]

the units of the symbols of the model, see point_values.

required

Returns:

Type Description
list[str]

<target> = <value> <unit> for a dimension which changes one target,

list[str]

else <dim> = <label>.

point_scale

point_scale(values)

Get the range which maps the values of the points of a dimension onto colours.

Returns:

Type Description
tuple[float, float, bool] | None

(low, high, log), logarithmic when all values are positive and the

tuple[float, float, bool] | None

largest is more than LOG_RATIO times the smallest, else linear from

tuple[float, float, bool] | None

the smallest to the largest value; None if the values do not span a

tuple[float, float, bool] | None

range (a single value, equal values or a value which is not finite).

format_value

format_value(value)

Format a value of a dimension: six significant digits, a short exponent.

label_text

label_text(label)

Get the text of a label of a dimension, a float formatted as a value.

colorbar_arguments

colorbar_arguments(styles)

Get the colour bar of points whose colours are of the colour scale COLORMAP.

The points take the first _COLORMAP_END of the colour scale, since its light yellow end is hard to see on white, so the colour bar shows that part of the scale over the range of the values of the points: the colour of the bar at the value of a point is the colour of its line and the bar shows no value no line has. A dimension which does not change one target gets a categorical bar of a band per point, labelled by the labels of its points, up to MAX_BANDS points, a bar of their positions above.

Parameters:

Name Type Description Default
styles PointStyle

the style of the points, see point_styles, of a curve without a colour of its own.

required

Returns:

Type Description
dict[str, Any] | None

The keyword arguments of ChartPlot.colorbar, None for points which

dict[str, Any] | None

span no range.

point_styles

point_styles(lines, over, color, dimensions, units)

Get the colours, line styles, labels and colour bar of the lines of a curve.

The points are the ones the lines draw, i.e. the labels left after the sel of the data, each found by its label in its dimension.

Parameters:

Name Type Description Default
lines Sequence[Line | BandLine]

the lines of the curve or band.

required
over Sequence[str]

the ids of the dimensions it is drawn over.

required
color str | None

the colour of the style of the curve, None without.

required
dimensions Sequence[Dimension | None]

the dimension of the scan of every one of over, None where it is not known.

required
units Mapping[str, str]

the units of the symbols of the model, see point_values.

required

Returns:

Type Description
PointStyle

The style shared by the serializers.

Raises:

Type Description
ValueError

for more points of a second dimension than line styles.