tellurium.plotting package

Submodules

tellurium.plotting.api module

tellurium.plotting.api.clearTiledFigure()[source]
tellurium.plotting.api.newLowerTriFigure(*args, **kwargs)[source]
tellurium.plotting.api.newTiledFigure(*args, **kwargs)[source]
tellurium.plotting.api.nextFigure(*args, **kwargs)[source]
tellurium.plotting.api.plot(x, y, show=True, **kwargs)[source]

Create a 2D scatter plot.

Parameters:
  • x – A numpy array describing the X datapoints. Should have the same number of rows as y.

  • y – A numpy array describing the Y datapoints. Should have the same number of rows as x.

  • tag – A tag so that all traces of the same type are plotted using same color/label (for e.g. multiple stochastic traces).

  • tags – Like tag, but for multiple traces.

  • name – The name of the trace.

  • label – The name of the trace.

  • names – Like name, but for multiple traces to appear in the legend.

  • labels – The name of the trace.

  • alpha – Floating point representing the opacity ranging from 0 (transparent) to 1 (opaque).

  • show – show=True (default) shows the plot, use show=False to plot multiple simulations in one plot

  • showlegend – Whether to show the legend or not.

  • mode – Can be set to ‘markers’ to generate scatter plots, or ‘dash’ for dashed lines.

import numpy as np, tellurium as te
result = np.array([[1,2,3,4], [7.2,6.5,8.8,10.5], [9.8, 6.5, 4.3,3.0]])
te.plot(result[:,0], result[:,1], name='Second column', show=False)
te.plot(result[:,0], result[:,2], name='Third column', show=False)
te.show(reset=False) # does not reset the plot after showing plot
te.plot(result[:,0], result[:,3], name='Fourth column', show=False)
te.show()
tellurium.plotting.api.plot_text(x, y, text, show=True, **kwargs)[source]
tellurium.plotting.api.show(reset=True)[source]
tellurium.plotting.api.tiledFigure()[source]

tellurium.plotting.engine module

Defines the main classes for plotting which are implemented by the different ploting frameworks, i.e. matplotlib or plotly.

class tellurium.plotting.engine.LowerTriFigure[source]

Bases: TiledFigure

cycleMarker()[source]
class tellurium.plotting.engine.PlottingEngine[source]

Bases: object

Abstract parent class of all PlottingEngines.

Helper functions on this class provide methods to create new figures from various datasets.

accumulateTimecourse(m, xlabel=None, ylabel=None, title=None, linewidth=2, xlim=None, ylim=None, logx=False, logy=False, xscale='linear', yscale='linear', grid=False, ordinates=None, tag=None, labels=None, figsize=(6, 4), savefig=None, dpi=80, alpha=1.0, **kwargs)[source]

Accumulates the traces instead of plotting (like matplotlib with show=False). Call show() to show the plot.

Parameters:

m – An array returned by RoadRunner.simulate.

figureFromTimecourse(m, ordinates=None, tag=None, alpha=None, title=None, xlim=None, ylim=None, **kwargs)[source]

Generate a new figure from a timecourse simulation.

Parameters:

m – An array returned by RoadRunner.simulate.

Returns:

instance of PlottingFigure

figureFromXY(x, y, **kwargs)[source]

Generate a new figure from x/y data.

Parameters:
  • x – A column representing x data.

  • y – Y data (may be multiple columns).

Returns:

instance of PlottingFigure

abstract newFigure(title=None, logX=False, logY=False, layout=None, xlabel=None, ylabel=None, xlim=None, ylim=None)[source]

Returns PlottingFigure. Needs to be implemented in base class.

abstract newTiledFigure(title=None, logX=False, logY=False, layout=None, xlabel=None, ylabel=None)[source]

Returns PlottingTiledFigure. Needs to be implemented in base class.

plot(x, y, show=True, **kwargs)[source]

Plot x & y data.

Parameters:
  • x – x data.

  • y – y data (can be multiple columns).

Returns:

instance of PlottingFigure

plotTimecourse(m, xlabel=None, ylabel=None, title=None, linewidth=2, xlim=None, ylim=None, logx=False, logy=False, xscale='linear', yscale='linear', grid=False, ordinates=None, tag=None, labels=None, figsize=(6, 4), savefig=None, dpi=80, alpha=1.0, **kwargs)[source]

Plots a timecourse from a simulation.

Parameters:

m – An array returned by RoadRunner.simulate.

plot_text(x, y, text, show=True, **kwargs)[source]
show(reset=True)[source]

Shows the traces accummulated from accumulateTimecourse.

Parameters:

reset – Reset the traces so the next plot will start out empty?

class tellurium.plotting.engine.PlottingFigure(title=None, layout=<tellurium.plotting.engine.PlottingLayout object>, logx=False, xlabel=None, logy=False, ylabel=None, selections=None)[source]

Bases: object

addXYDataset(x_arr, y_arr, color=None, tag=None, name=None, filter=True, alpha=None, mode=None, logx=None, logy=None, scatter=None, error_y_pos=None, error_y_neg=None, showlegend=None, text=None, dash=None, linewidth=None, marker=None, mec=None, mfc=None, ms=None, mew=None, edgecolor=None, bottom=None, bartype=None, y2=None)[source]

Adds an X/Y dataset to the plot.

Parameters:
  • x_arr – A numpy array describing the X datapoints. Should have the same size as y_arr.

  • y_arr – A numpy array describing the Y datapoints. Should have the same size as x_arr.

  • color – The color to use (not supported by all backends).

  • tag – A tag so that all traces of the same type are plotted consistently (for e.g. multiple stochastic traces).

  • name – The name of the trace.

  • filter – Apply the self.selections filter?

  • alpha – Floating point representing the opacity.

  • mode – Either ‘lines’ or ‘markers’ (defaults to ‘lines’).

getDatasets()[source]

Get an iterable of all datasets.

getMergedTaggedDatasets()[source]
plot(x, y, colnames=None, title=None, xlabel=None, logx=None, logy=None, ylabel=None, alpha=None, name=None, names=None, tag=None, tags=None, scatter=None, error_y_pos=None, error_y_neg=None, showlegend=None, label=None, labels=None, text=None, dash=None, color=None)[source]

Plot x & y data.

abstract render()[source]

Creates the figure.

abstract save(filename, format)[source]

Save figure.

Parameters:
  • filename – filename to save to

  • format – format to save

Returns:

setXLim(xlim)[source]

Set the min/max x limits of the figure. :param xlim: tuple of min/max values

setYLim(ylim)[source]

Set the min/max y limits of the figure. :param ylim: tuple of min/max values

class tellurium.plotting.engine.PlottingLayout[source]

Bases: object

Layout information for plot.

class tellurium.plotting.engine.TiledFigure[source]

Bases: object

cycleMarker()[source]
isExhausted()[source]
abstract nextFigure(*args, **kwargs)[source]
tellurium.plotting.engine.filterWithSelections(self, name, selections)[source]

This function is intended to be used as an argument to the filter built-in. It filters out unwanted traces (only those variables specified in selections will be passed through).

Parameters:
  • name – The symbol we want to potentially filter

  • selections – The list of selections we want to plot

tellurium.plotting.engine_mpl module

Matplotlib implementation of the plotting engine.

class tellurium.plotting.engine_mpl.MatplotlibEngine[source]

Bases: PlottingEngine

Matplotlib engine.

classmethod newFigure(title=None, logX=False, logY=False, layout=None, xlabel=None, ylabel=None, xlim=None, ylim=None)[source]

Returns a figure object.

class tellurium.plotting.engine_mpl.MatplotlibFigure(layout=<tellurium.plotting.engine.PlottingLayout object>, use_legend=True, xlabel=None, ylabel=None, title=None, linewidth=None, xlim=None, ylim=None, logx=None, logy=None, xscale=None, yscale=None, grid=None, ordinates=None, tag=None, labels=None, figsize=(9, 6), savefig=None, dpi=None)[source]

Bases: PlottingFigure

MatplotlibFigure.

render()[source]

Plot the figure. Call this last.

save(filename, format)[source]

Save figure.

Parameters:
  • filename – filename to save to

  • format – format to save

Returns:

tellurium.plotting.engine_null module

Plotly implementation of the plotting engine.

class tellurium.plotting.engine_null.NullEngine[source]

Bases: PlottingEngine

PlottingEngine using plotly.

newFigure(title=None, logX=False, logY=False, layout=<tellurium.plotting.engine.PlottingLayout object>, xlabel=None, ylabel=None)[source]

Returns a figure object.

newLowerTriFigure(title=None, rows=None, cols=None)[source]
newTiledFigure(title=None, rows=None, cols=None)[source]

Returns PlottingTiledFigure. Needs to be implemented in base class.

class tellurium.plotting.engine_null.NullFigure(title=None, layout=<tellurium.plotting.engine.PlottingLayout object>, logx=False, logy=False, save_to_pdf=False, xlabel=None, ylabel=None)[source]

Bases: PlottingFigure

PlotlyFigure.

render()[source]

Creates the figure.

save(filename, format)[source]

Save figure.

Parameters:
  • filename – filename to save to

  • format – format to save

Returns:

class tellurium.plotting.engine_null.PlotlyLowerTriFigure(engine, rows, cols)[source]

Bases: PlotlyTiledFigure, LowerTriFigure

makeTitles()[source]
renderIfExhausted()[source]
class tellurium.plotting.engine_null.PlotlyTiledFigure(engine, rows, cols)[source]

Bases: TiledFigure

nextFigure(*args, **kwargs)[source]
renderIfExhausted()[source]

tellurium.plotting.engine_plotly module

Plotly implementation of the plotting engine.

class tellurium.plotting.engine_plotly.PlotlyEngine[source]

Bases: PlottingEngine

PlottingEngine using plotly.

newFigure(title=None, logX=False, logY=False, layout=<tellurium.plotting.engine.PlottingLayout object>, xlabel=None, ylabel=None)[source]

Returns a figure object.

newLowerTriFigure(title=None, rows=None, cols=None)[source]
newStackedFigure(title=None, logX=False, logY=False, layout=<tellurium.plotting.engine.PlottingLayout object>)[source]

Returns a figure object.

newTiledFigure(title=None, rows=None, cols=None)[source]

Returns PlottingTiledFigure. Needs to be implemented in base class.

class tellurium.plotting.engine_plotly.PlotlyFigure(title=None, layout=<tellurium.plotting.engine.PlottingLayout object>, logx=False, logy=False, save_to_pdf=False, xlabel=None, ylabel=None)[source]

Bases: PlottingFigure

PlotlyFigure.

getArgsForDataset(dataset)[source]
getScatterGOs()[source]
makeLayout()[source]
render()[source]

Plot the figure. Call this last.

save(filename, format)[source]

Save figure.

Parameters:
  • filename – filename to save to

  • format – format to save

Returns:

class tellurium.plotting.engine_plotly.PlotlyLowerTriFigure(engine, rows, cols)[source]

Bases: PlotlyTiledFigure, LowerTriFigure

makeTitles()[source]
renderIfExhausted()[source]
class tellurium.plotting.engine_plotly.PlotlyStackedFigure(title=None, layout=<tellurium.plotting.engine.PlottingLayout object>, logx=False, logy=False)[source]

Bases: PlotlyFigure

Stacked figure.

render()[source]

Plot the figure. Call this last.

class tellurium.plotting.engine_plotly.PlotlyTiledFigure(engine, rows, cols)[source]

Bases: TiledFigure

nextFigure(*args, **kwargs)[source]
renderIfExhausted()[source]

tellurium.plotting.factory module

Factory for the engines.

class tellurium.plotting.factory.PlottingEngineFactory(engine)[source]

Bases: object

tellurium.plotting.factory.getEngines()[source]
tellurium.plotting.factory.getPlottingEngineFactory(engine)[source]

Module contents