Plotting time-series data

BioSimSpace provides several tools that provide additional functionality when working interactively. One of these is the plot function that enables graphing of time series data. This is simply a wrapper around Matplotlib to quickly produce nicely formatted graphs for inclusion in a Jupyter notebook.

(Here we assume that you have initalised a BioSimspace process, see here for details.)

To plot the total energy of the system as a function of time:

import BioSimSpace as BSS

# Get the time and energy records.
time = process.getTime(time_series=True)
energy = process.getTotalEnergy(time_series=True)

# Plot the data.
BSS.Notebook.plot(x=time, y=energy, xlabel="Time (ns)", ylabel="Energy (kcal/mol")

(Note that in this example we assume that the process above generates energy record data.)

If you omit the x keyword argument then the y data values will be plotted against their list index.

The logx and logy keyword arguments can be used to adjust the axis scaling. For example, to use a logarithic axis for the time record data:

BSS.Notebook.plot(x=time, y=energy, xlabel="Time (ns)", ylabel="Energy (kcal/mol", logx=True)

The plot function returns a matplotlib.pyplot object that can be further customised to your needs.