Simulation Output Utilities

vivarium.plots.simulation_output.get_variable_title(path)[source]

Get figure title from a variable path.

Parameters

path – Path to the variable.

Returns

String representation of the variable suitable for a figure title.

vivarium.plots.simulation_output.plot_simulation_output(timeseries_raw, settings: Optional[Dict[str, Any]] = None, out_dir=None, filename='simulation')[source]

Plot simulation output, with rows organized into separate columns.

Arguments::

timeseries (dict): This can be obtained from simulation output with convert_to_timeseries() settings (dict): Accepts the following keys:

  • column_width (int): the width (inches) of each column in the figure

  • max_rows (int): ports with more states than this number of states get wrapped into a new column

  • remove_zeros (bool): if True, timeseries with all zeros get removed

  • remove_flat (bool): if True, timeseries with all the same value get removed

  • remove_first_timestep (bool): if True, skips the first timestep

  • skip_ports (list): entire ports that won’t be plotted

  • show_state (list): with [('port_id', 'state_id')] for all states that will be highlighted, even if they are otherwise to be removed TODO: Obsolete?

vivarium.plots.simulation_output.plot_variables(output, variables, column_width=8, row_height=1.2, row_padding=0.8, linewidth=3.0, sci_notation=False, default_color='tab:blue', out_dir=None, filename='variables')[source]

Create a simple figure with a timeseries for every variable.

Parameters
  • output – Simulation output as a map from variable names or paths to timeseries data. Should contain a time key whose value is a list of time points.

  • variables – The variables to plot. May be a list of variable names (if simulation output keys are just variable names) or a dictionary with keys variable (for the variable path), color (for the color to use for the plot), and display (the variable name to display). If display is not provided, the result of calling get_variable_title() on the variable path is used.

  • column_width – Figure width.

  • row_height – Height of each row. Each variable gets one row.

  • row_padding – Space between rows.

  • linewidth – Width of timeseries lines.

  • sci_notation – Either False for no scientific notation or an integer \(x\) such that scientific notation will be used for values outside the range \([10^{-x}, 10^x]\).

  • default_color – Default timeseries color.

  • out_dir – Output directory.

  • filename – Output filename.

Returns

The figure.

vivarium.plots.simulation_output.set_axes(ax, show_xaxis=False, sci_notation=False, y_offset=0.0)[source]

Set up plot axes.

Parameters
  • ax – The axes to set up.

  • show_xaxis – Whether to show the x axis.

  • sci_notation – Either False to not use scientific notation or an integer \(x\) such that scientific notation will be used outside the range \([10^{-x}, 10^x]\).

  • y_offset – Horizontal distance between axis offset text (typically for scientific notation) and the y-axis.