sbmlsim.plot

Plotting in sbmlsim.

Submodules

Package Contents

Classes

Figure

A figure consists of multiple subplots.

Plot

Plot panel.

Axis

Axis object.

SubPlot

A SubPlot holds a plot in a Figure.

Curve

Curve object.

ColorType

ColorType class.

MarkerType

MarkerType options.

class sbmlsim.plot.Figure(experiment, sid, name=None, subplots=None, height=None, width=None, num_rows=1, num_cols=1)[source]

Bases: BasePlotObject

A figure consists of multiple subplots.

A reference to the experiment is required, so the plot can resolve the datasets and the simulations.

Parameters:
  • experiment (SimulationExperiment) –

  • sid (str) –

  • name (str) –

  • subplots (List[SubPlot]) –

  • height (float) –

  • width (float) –

  • num_rows (int) –

  • num_cols (int) –

property height: float

Get height.

Return type:

float

property width: float

Get width.

Return type:

float

property plots: List[Plot]

Get plots in this figure.

Return type:

List[Plot]

fig_dpi :int = 72
fig_facecolor :str = white
fig_subplots_wspace :float = 0.3
fig_subplots_hspace :float = 0.3
panel_width :float = 7.0
panel_height :float = 5.0
fig_titlesize :int = 25
fig_titleweight :str = bold
axes_titlesize :int = 20
axes_titleweight :str = bold
axes_labelsize :int = 18
axes_labelweight :str = bold
xtick_labelsize :int = 15
ytick_labelsize :int = 15
legend_fontsize :int = 13
legend_position :str = inside
legend_loc :str = best
_area_interpolation_points :int = 300
__repr__()

Get representation string.

Return type:

str

num_subplots()

Get number ofsubplots.

Return type:

int

num_panels()

Get number of panel spots for plots.

Plots can span multiple of these panels.

Return type:

int

set_title(title)

Set title.

create_plots(xaxis=None, yaxis=None, legend=True)

Create plots in the figure.

Settings are applied to all generated plots. E.g. if an xaxis is provided all plots have a copy of this xaxis.

Parameters:
  • xaxis (Axis) –

  • yaxis (Axis) –

  • legend (bool) –

Return type:

List[Plot]

get_plots()

Get plots in this figure.

Return type:

List[Plot]

add_subplot(plot, row, col, row_span=1, col_span=1)

Add plot as subplot to figure.

Be careful that individual subplots do not overlap when adding multiple subplots.

Parameters:
  • plot (Plot) – Plot to add as subplot.

  • row (int) – row position for plot in [1, num_rows]

  • col (int) – col position for plot in [1, num_cols]

  • row_span (int) – span of figure with row + row_span <= num_rows

  • col_span (int) – span of figure with col + col_span <= num_cols

Return type:

Plot

add_plots(plots, copy_plots=False)

Add plots to figure.

For every plot a subplot is generated.

Parameters:
  • plots (List[Plot]) –

  • copy_plots (bool) –

Return type:

None

static from_plots(sid, plots)

Create figure object from list of plots.

Parameters:

plots (List[Plot]) –

Return type:

Figure

to_dict()

Convert to dictionary.

class sbmlsim.plot.Plot(sid, name=None, xaxis=None, yaxis=None, yaxis_right=None, curves=None, areas=None, legend=True, facecolor=None, title_visible=True, height=None, width=None)[source]

Bases: BasePlotObject

Plot panel.

A plot is the basic element of a plot. This corresponds to a single panel or axes combination in a plot. Multiple plots create a figure.

Parameters:
  • sid (str) –

  • name (str) –

  • xaxis (Axis) –

  • yaxis (Axis) –

  • yaxis_right (Axis) –

  • curves (List[Curve]) –

  • areas (List[ShadedArea]) –

  • legend (bool) –

  • facecolor (ColorType) –

  • title_visible (bool) –

  • height (float) –

  • width (float) –

property figure: Figure

Get figure for plot.

Return type:

Figure

property experiment

Get simulation experiment for this plot.

property title: str

Get title.

Return type:

str

property xaxis: Axis

Get xaxis.

Return type:

Axis

property yaxis: Axis

Get yaxis.

Return type:

Axis

property yaxis_right: Axis

Get right yaxis.

Return type:

Axis

property curves: List[Curve]

Get curves.

Return type:

List[Curve]

property areas: List[ShadedArea]

Get areas.

Return type:

List[ShadedArea]

__repr__()

Get representation string.

Return type:

str

__str__()

Get string.

Return type:

str

__copy__()

Copy the existing object.

Return type:

Plot

to_dict()

Convert to dictionary.

set_title(title)

Set title.

Parameters:

title (str) –

Return type:

None

set_xaxis(label, unit=None, **kwargs)

Set axis with all axes attributes.

All argument of Axis are supported.

Parameters:
  • label (Optional[Union[str, Axis]]) –

  • unit (str) –

Return type:

None

set_yaxis(label, unit=None, **kwargs)

Set axis with all axes attributes.

All argument of Axis are supported.

Parameters:
  • label (Union[str, Axis]) –

  • unit (str) –

  • label_visible

  • kwargs

Returns:

set_yaxis_right(label, unit=None, **kwargs)

Set axis with all axes attributes.

All argument of Axis are supported.

Parameters:
  • label (Union[str, Axis]) – label of Axis

  • unit (str) – unit of the Axis (added to label)

  • label_visible – boolean flag to make the axis visible or not.

  • kwargs

Returns:

Return type:

None

static _create_axis(label, unit=None, **kwargs)
Parameters:
  • label (Optional[Union[str, Axis]]) –

  • unit (str) –

Return type:

Optional[Axis]

_set_order(abstract_curve)

Set order for given AbstractCurve.

Parameters:

abstract_curve (AbstractCurve) –

add_curve(curve)

Add Curve via the helper function.

All additions must go via this function to ensure data registration.

Parameters:

curve (Curve) –

add_area(area)

Add ShadedArea via the helper function.

All additions must go via this function to ensure data registration.

Parameters:

area (ShadedArea) –

curve(x, y, xerr=None, yerr=None, type=CurveType.POINTS, style=None, yaxis_position=None, **kwargs)

Create curve and add to plot.

Parameters:
add_data(xid, yid, yid_sd=None, yid_se=None, count=None, dataset=None, task=None, label='__yid__', type=CurveType.POINTS, style=None, yaxis_position=None, **kwargs)

Add a data curve to the plot.

Styling of curve is based on the provided style and matplotlib kwargs.

Parameters:
  • xid (str) – index of x data

  • yid (str) – index of y data

  • yid_sd – index of y SD data

  • yid_se – index of y SE data

  • count (Union[int, str]) – count for curve (number of subjects)

  • dataset (str) – dataset id

  • task (str) – task id

  • label (Optional[str]) – label for curve (label=None for no label)

  • type (CurveType) – type of curve (default points)

  • style (Style) – style for curve

  • yaxis_position (YAxisPosition) – position of yaxis for this curve

  • kwargs – matplotlib styling kwargs

Returns:

class sbmlsim.plot.Axis(label=None, unit=None, name=None, scale=AxisScale.LINEAR, min=None, max=None, reverse=False, grid=False, label_visible=True, ticks_visible=True, style=None)[source]

Bases: BasePlotObject

Axis object.

Parameters:
  • label (str) –

  • unit (str) –

  • name (str) –

  • scale (AxisScale) –

  • min (float) –

  • max (float) –

  • reverse (bool) –

  • grid (bool) –

  • label_visible (bool) –

  • ticks_visible (bool) –

  • style (Style) –

property scale: AxisScale

Get axis scale.

Return type:

AxisScale

__repr__()

Get string.

Return type:

str

__str__()

Get string.

Return type:

str

__copy__()

Copy axis object.

Return type:

Axis

to_dict()

Convert to dictionary.

class sbmlsim.plot.SubPlot(plot, row=None, col=None, row_span=1, col_span=1, sid=None, name=None)[source]

Bases: BasePlotObject

A SubPlot holds a plot in a Figure.

The SubPlot defines the layout used by the plot, i.e., the position and number of panels the plot is spanning.

Parameters:
  • plot (Plot) –

  • row (int) –

  • col (int) –

  • row_span (int) –

  • col_span (int) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

__str__()

Get string.

class sbmlsim.plot.Curve(x, y, sid=None, name=None, xerr=None, yerr=None, order=None, type=CurveType.POINTS, style=None, yaxis_position=None, **kwargs)[source]

Bases: AbstractCurve

Curve object.

Parameters:
__repr__()

Get representation string.

Return type:

str

__str__()

Get string.

Return type:

str

static _add_default_style_kwargs(d, dtype)

Add the default plotting style arguments.

Parameters:
  • d (Dict) –

  • dtype (str) –

Return type:

Dict

to_dict()

Convert Curve to dictionary.

class sbmlsim.plot.ColorType(color)[source]

ColorType class.

Encoding color information used in plots.

Parameters:

color (str) –

to_dict()

Convert for serialization.

__repr__()

Get string representation.

Return type:

str

static parse_color(color, alpha=1.0)

Parse given color and add alpha information.

Parameters:
  • color (str) –

  • alpha (float) –

Returns:

ColorType or None

Return type:

Optional[ColorType]

class sbmlsim.plot.MarkerType[source]

Bases: enum.Enum

MarkerType options.

NONE = 1
SQUARE = 2
CIRCLE = 3
DIAMOND = 4
XCROSS = 5
PLUS = 6
STAR = 7
TRIANGLEUP = 8
TRIANGLEDOWN = 9
TRIANGLELEFT = 10
TRIANGLERIGHT = 11
HDASH = 12
VDASH = 13