Common Plots¶
The myokit.lib
module provides a number of functions that take simulation
logs as input and create some common (or less common) plots.
This module uses matplotlib
for visualisation.

myokit.lib.plots.
cumulative_current
(log, currents, axes, labels=None, colors=None, integrate=False)¶ Plots a number of currents, one on top of the other, with the positive and negative parts of the current plotted separately.
The advantage of this type of plot is that it shows the relative size of each current versus the others, and gives an indication of the total positive and negative current in a model.
Accepts the following arguments:
log
 A:class:myokit.DataLog containing all the data to plot.
currents
 A list of keys, where each key corresponds to a current stored in
log
. axes
 The matplotlib axes to create the plot on.
labels
 Can be used to pass in a list containing the label to set for each current.
colors
 Can be used to pass in a list containing the colors to set for each current.
integrate
 Set this to
True
to plot total carried charge instead of currents.
The best results are obtained if relatively constant currents are specified early. Another rule of thumb is to specify the currents roughly in the order they appear during an AP.

myokit.lib.plots.
current_arrows
(log, voltage, currents, axes=None)¶ Draws a graph of voltage versus time with arrows to indicate which currents are active at which stage of the action potential.
The argument,
log
should be a:class:myokit.DataLog containing the data needed for the plot. The argumentvoltage
should be the key inlog
that maps to the membrane potential.The list
currents
should contain all keys of currents to display.Returns a matplotlib axes object.

myokit.lib.plots.
simulation_times
(time=None, realtime=None, evaluations=None, mode='stair', axes=None, nbuckets=50, label=None)¶ Draws a graph of step sizes used during a simulation.
Data can be passed in as
time
(simulation time)realtime
(benchmarked time during the simulation) andevaluations
(the number of evaluations needed for each step). Which of these fields are required dependens on the chosen plotmode
:stair
 Draws
time
on the xaxis, and the step number on the yaxis. In this plot, a high slope means the integrator is taking lots of steps. stair_inverse
 Draws
time
on the yaxis, and the step number on the xaxis. load
 Draws
time
on the xaxis, and log(1 / step size) on the yaxis. In this plot, high values on the yaxis should be found near difficult times on the xaxis histo
 Lumps
time
into buckets (whose number can be specified using the argumentnbuckets
) and counts the number of steps in each bucket. In the final result, the times corresponding to the buckets are plotted on the x axis and the number of evaluations in each bucket is plotted on the y axis. time_per_step
 Uses the
realtime
argument to calculate the time taken to advance the solution each step. In the resulting plot, the step count is plotted on the xaxis, while the yaxis shows the time spent at this point. eval_per_step
 Uses the
evaluations
entry to calculate the number of rhs evaluations required for each step. In the resulting plot, the step number is plotted on the xaxis, and the number of rhs evaluations for each step is plotted on the yaxis.
The argument
axes
can be used to pass in a matplotlib axes object to be used for the plot. If none are given, the current axes obtained frompyplot.gca()
are used.Returns a matplotlib axes object.