API Reference¶
Simulation control¶
Control interface¶
- class Control(**kwargs)[source]¶
Control panel widget for an interactive simulation.
- Parameters
model – A simulation model with discrete steps.
parameters (dict, optional) – Dictionary of parameter names and values (default None). Entries of type
Range
,IntRange
, andValues
will be displayed as interactive widgets.variables (str of list of str, optional) – Model attributes to display in the control panel (default None).
Parameter ranges¶
- class Range(vmin=0, vmax=1, vdef=None)[source]¶
A range of parameter values that can be passed to
Control
.
Visualization widgets¶
Pre-defined plots¶
- class Lineplot(**kwargs)[source]¶
Chart widget for one or multiple data-series.
- Parameters
control (Control) – The simulation control panel.
y (str or function or list) – Data collector(s) for the y axis.
ylabel (str or list of str, optional) – Label(s) for the y axis.
x (str, or function, optional) – Data collector for the x axis (default ‘t’).
xlabel (str, optional) – Label for the x axis (default ‘Time-step t’).
- class Scatterplot(**kwargs)[source]¶
Chart widget for a scatterplot.
- Parameters
control (Control) – The simulation control panel.
xy (str or function) – Data collector for the x and y coordinates (see Data collectors).
c (str or function) – Data collector for the colors (see Data Collector).
Custom widgets¶
- class CustomWidget(**kwargs)[source]¶
Custom visualization widget.
- Parameters
control (Control) – The simulation control panel.
source (dict of str) –
Dictionary of strings with javascript functions that define the visualization of the widget. Possible entries are:
’setup’: Called when a new view is rendered.
’update’: Called when new data is synched.
’reset’: Called when the simulation is reset.
Functions can access the widget view and widget model with view and view.model. The D3 library can be accessed with d3. Collected data is passed to the update function as data.
config (dict) – Configuration data that can be accessed by the visualization functions defined in source, using view.model.config.
data (dict) – Dictionary of variable names and ref:collectors.
- class Matplot(**kwargs)[source]¶
Matplotlib subplots widget with a custom update function.
- Parameters
control (Control) – The simulation control panel.
update (function) – Function that takes (model, fig, ax) as input.
*args – Forwarded to
matplotlib.pyplot.subplots()
.*kwargs – Forwarded to
matplotlib.pyplot.subplots()
.