Skip to content
Kyle Medley edited this page Mar 13, 2016 · 6 revisions

Plotting Examples

Setting Line Style

Plotting with line styles

import roadrunner
from roadrunner import RoadRunner
import matplotlib
from matplotlib.artist import setp

r = RoadRunner('model.xml')

r.setIntegrator('gillespie')
r.integrator.variable_step_size = True
r.getIntegrator().setValue('seed', 0)
result = r.simulate(0,10)
plots = r.plot (result, show=False)

setp(plots[0], linestyle='-')
setp(plots[1], linestyle='--')
setp(plots[2], linestyle='-.')
setp(plots[3], linestyle=':')
setp(plots[4], linewidth=3)
setp(plots[5], linewidth=5)

r.plotLegend()
r.showPlot()

model.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.7.0 on 2016-03-13 11:05 with libSBML version 5.11.3. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
  <model id="__main" name="__main">
    <listOfCompartments>
      <compartment sboTerm="SBO:0000410" id="default_compartment" spatialDimensions="3" size="1" constant="true"/>
    </listOfCompartments>
    <listOfSpecies>
      <species id="MH" compartment="default_compartment" initialConcentration="50" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
      <species id="MS" compartment="default_compartment" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
      <species id="MD" compartment="default_compartment" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
      <species id="FH" compartment="default_compartment" initialConcentration="50" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
      <species id="FS" compartment="default_compartment" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
      <species id="FD" compartment="default_compartment" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
    </listOfSpecies>
    <listOfReactions>
      <reaction id="MJ00" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="MH" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="MS" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> MH </ci>
              <cn> 0.2 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="MJ02" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="MH" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="MD" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> MH </ci>
              <cn> 0.01 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="MJ10" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="MS" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="MH" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> MS </ci>
              <cn> 0.1 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="MJ12" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="MS" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="MD" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> MS </ci>
              <cn> 0.3 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="FJ00" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="FH" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="FS" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> FH </ci>
              <cn> 0.1 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="FJ02" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="FH" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="FD" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> FH </ci>
              <cn> 0.01 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="FJ10" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="FS" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="FH" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> FS </ci>
              <cn> 0.1 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="FJ12" reversible="true" fast="false">
        <listOfReactants>
          <speciesReference species="FS" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="FD" stoichiometry="1" constant="true"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> FS </ci>
              <cn> 0.3 </cn>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
    </listOfReactions>
  </model>
</sbml>