sbmlsim.plot.plotting

Classes for storing plotting information.

The general workflow of generating plotting information is the following.

  1. Within simulation experiments abstract plotting information is stored.

    i.e., how from the data plots can be generated.

Working with multidimensional data ! Additional settings are required which allow to define how things

are plotted. E.g. over which dimensions should an error be calculated and which dimensions should be plotted individually.

Module Contents

Classes

BasePlotObject

Base class for plotting objects.

LineType

LineType options.

MarkerType

MarkerType options.

CurveType

CurveType options.

ColorType

ColorType class.

Line

Style of a line.

Marker

Style of a marker.

Fill

Style of a fill.

Style

Style class.

AxisScale

Scale of the axis.

YAxisPosition

Position of yaxis.

Axis

Axis object.

AbstractCurve

Base class of Curves and ShadedAreas.

Curve

Curve object.

ShadedArea

ShadedArea class.

Plot

Plot panel.

SubPlot

A SubPlot holds a plot in a Figure.

Figure

A figure consists of multiple subplots.

Attributes

logger

DEFAULT_COLORS

sbmlsim.plot.plotting.logger[source]
sbmlsim.plot.plotting.DEFAULT_COLORS = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f',...[source]
class sbmlsim.plot.plotting.BasePlotObject(sid, name)[source]

Base class for plotting objects.

Parameters:
  • sid (str) –

  • name (str) –

class sbmlsim.plot.plotting.LineType[source]

Bases: enum.Enum

LineType options.

NONE = 1[source]
SOLID = 2[source]
DASH = 3[source]
DOT = 4[source]
DASHDOT = 5[source]
DASHDOTDOT = 6[source]
class sbmlsim.plot.plotting.MarkerType[source]

Bases: enum.Enum

MarkerType options.

NONE = 1[source]
SQUARE = 2[source]
CIRCLE = 3[source]
DIAMOND = 4[source]
XCROSS = 5[source]
PLUS = 6[source]
STAR = 7[source]
TRIANGLEUP = 8[source]
TRIANGLEDOWN = 9[source]
TRIANGLELEFT = 10[source]
TRIANGLERIGHT = 11[source]
HDASH = 12[source]
VDASH = 13[source]
class sbmlsim.plot.plotting.CurveType[source]

Bases: enum.Enum

CurveType options.

POINTS = 1[source]
BAR = 2[source]
BARSTACKED = 3[source]
HORIZONTALBAR = 4[source]
HORIZONTALBARSTACKED = 5[source]
class sbmlsim.plot.plotting.ColorType(color)[source]

ColorType class.

Encoding color information used in plots.

Parameters:

color (str) –

to_dict()[source]

Convert for serialization.

__repr__()[source]

Get string representation.

Return type:

str

static parse_color(color, alpha=1.0)[source]

Parse given color and add alpha information.

Parameters:
  • color (str) –

  • alpha (float) –

Returns:

ColorType or None

Return type:

Optional[ColorType]

class sbmlsim.plot.plotting.Line[source]

Style of a line.

type: LineType[source]
color: ColorType[source]
thickness: float = 2.0[source]
to_dict()[source]

Convert to dictionary for serialization.

Return type:

Dict[str, Any]

class sbmlsim.plot.plotting.Marker[source]

Style of a marker.

size: float = 6.0[source]
type: MarkerType[source]
fill: ColorType[source]
line_color: ColorType[source]
line_thickness: float = 1.0[source]
to_dict()[source]

Convert to dictionary for serialization.

Return type:

Dict[str, Any]

class sbmlsim.plot.plotting.Fill[source]

Style of a fill.

color: ColorType[source]
second_color: ColorType[source]
to_dict()[source]

Convert to dictionary for serialization.

Return type:

Dict[str, Any]

class sbmlsim.plot.plotting.Style(sid=None, name=None, base_style=None, line=None, marker=None, fill=None)[source]

Bases: BasePlotObject

Style class.

Storing styling informatin about line, marker and fill. Styles can be derived from other styles based on the the base_style attribute.

Parameters:
  • sid (str) –

  • name (str) –

  • base_style (Optional[Style]) –

  • line (Optional[Line]) –

  • marker (Optional[Marker]) –

  • fill (Optional[Fill]) –

MPL2SEDML_LINESTYLE_MAPPING[source]
SEDML2MPL_LINESTYLE_MAPPING[source]
MPL2SEDML_MARKER_MAPPING[source]
SEDML2MPL_MARKER_MAPPING[source]
resolve_style()[source]

Resolve all basestyle information.

Resolves the actual style information.

Return type:

Style

__repr__()[source]

Get string presentation.

Return type:

str

__copy__()[source]

Copy axis object.

Return type:

Style

to_mpl_curve_kwargs()[source]

Convert to matplotlib curve keyword arguments.

Return type:

Dict

_mpl_error_kwargs()[source]

Define keywords for error bars.

Return type:

Dict[str, Any]

to_mpl_points_kwargs()[source]

Convert to matplotlib point curve keyword arguments.

Return type:

Dict[str, Any]

to_mpl_bar_kwargs()[source]

Convert to matplotlib bar curve keyword arguments.

to_mpl_area_kwargs()[source]

Define keyword dictionary for a shaded area.

Return type:

Dict[str, Any]

static from_mpl_kwargs(**kwargs)[source]

Create style from matplotlib arguments.

Parameters:
  • alpha – alpha setting

  • color – color setting

  • kwargs

Returns:

Return type:

Style

class sbmlsim.plot.plotting.AxisScale[source]

Bases: enum.Enum

Scale of the axis.

LINEAR = 1[source]
LOG10 = 2[source]
class sbmlsim.plot.plotting.YAxisPosition[source]

Bases: enum.Enum

Position of yaxis.

LEFT = 1[source]
RIGHT = 2[source]
class sbmlsim.plot.plotting.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[source]

Get axis scale.

Return type:

AxisScale

__repr__()[source]

Get string.

Return type:

str

__str__()[source]

Get string.

Return type:

str

__copy__()[source]

Copy axis object.

Return type:

Axis

to_dict()[source]

Convert to dictionary.

class sbmlsim.plot.plotting.AbstractCurve(sid, name, x=None, order=None, style=None, yaxis_position=None)[source]

Bases: BasePlotObject

Base class of Curves and ShadedAreas.

Parameters:
class sbmlsim.plot.plotting.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__()[source]

Get representation string.

Return type:

str

__str__()[source]

Get string.

Return type:

str

static _add_default_style_kwargs(d, dtype)[source]

Add the default plotting style arguments.

Parameters:
  • d (Dict) –

  • dtype (str) –

Return type:

Dict

to_dict()[source]

Convert Curve to dictionary.

class sbmlsim.plot.plotting.ShadedArea(x, yfrom, yto, order=None, style=None, yaxis_position=None, **kwargs)[source]

Bases: AbstractCurve

ShadedArea class.

Parameters:
__repr__()[source]

Get representation string.

Return type:

str

__str__()[source]

Get string.

Return type:

str

to_dict()[source]

Convert to dictionary.

class sbmlsim.plot.plotting.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[source]

Get figure for plot.

Return type:

Figure

property experiment[source]

Get simulation experiment for this plot.

property title: str[source]

Get title.

Return type:

str

property xaxis: Axis[source]

Get xaxis.

Return type:

Axis

property yaxis: Axis[source]

Get yaxis.

Return type:

Axis

property yaxis_right: Axis[source]

Get right yaxis.

Return type:

Axis

property curves: List[Curve][source]

Get curves.

Return type:

List[Curve]

property areas: List[ShadedArea][source]

Get areas.

Return type:

List[ShadedArea]

__repr__()[source]

Get representation string.

Return type:

str

__str__()[source]

Get string.

Return type:

str

__copy__()[source]

Copy the existing object.

Return type:

Plot

to_dict()[source]

Convert to dictionary.

set_title(title)[source]

Set title.

Parameters:

title (str) –

Return type:

None

set_xaxis(label, unit=None, **kwargs)[source]

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)[source]

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)[source]

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)[source]
Parameters:
  • label (Optional[Union[str, Axis]]) –

  • unit (str) –

Return type:

Optional[Axis]

_set_order(abstract_curve)[source]

Set order for given AbstractCurve.

Parameters:

abstract_curve (AbstractCurve) –

add_curve(curve)[source]

Add Curve via the helper function.

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

Parameters:

curve (Curve) –

add_area(area)[source]

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)[source]

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)[source]

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.plotting.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__()[source]

Get string.

class sbmlsim.plot.plotting.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[source]

Get height.

Return type:

float

property width: float[source]

Get width.

Return type:

float

property plots: List[Plot][source]

Get plots in this figure.

Return type:

List[Plot]

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

Get representation string.

Return type:

str

num_subplots()[source]

Get number ofsubplots.

Return type:

int

num_panels()[source]

Get number of panel spots for plots.

Plots can span multiple of these panels.

Return type:

int

set_title(title)[source]

Set title.

create_plots(xaxis=None, yaxis=None, legend=True)[source]

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()[source]

Get plots in this figure.

Return type:

List[Plot]

add_subplot(plot, row, col, row_span=1, col_span=1)[source]

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)[source]

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)[source]

Create figure object from list of plots.

Parameters:

plots (List[Plot]) –

Return type:

Figure

to_dict()[source]

Convert to dictionary.