EoN.Simulation_Investigation.animate

Simulation_Investigation.animate(frame_times=None, ts_plots=None, ts_list=None, nodelist=None, status_order=False, timelabel='$t$', pos=None, statuses_to_plot=None, **nx_kwargs)[source]

As in display, but this produces an animation.

To display an animation where sim is the Simulation_Investigation object simply do

sim.animate()
plt.show()

To save an animation [on a mac with appropriate additional libraries installed], you can do

ani = sim.animate()
ani.save(filename, fps=5, extra_args=['-vcodec', 'libx264'])

here ani is a matplotlib animation. See

https://matplotlib.org/api/_as_gen/matplotlib.animation.Animation.save.html

for more about the save command for matplotlib animations.

Arguments:

The same as in display, except that time is replaced by frame_times

frame_times (list/numpy array)
The times for animation frames. If nothing is given, then it uses 101 times between 0 and t[-1]
ts_plots (list of strings, defaults to statuses_to_plot, which defaults
to self._possible_statuses_)

if [] or False then the display only shows the network.

lists such as [['S'], ['I'], ['R']] or [['S', 'I'], ['R']]

equivalently ['S', 'I', 'R'] and ['SI', 'R'] will do the same but is problematic if a status has a string longer than 1.

denotes what should appear in the timeseries plots. The length of the list determines how many plots there are. If entry i is ['A', 'B'] then plot i has both 'A' and 'B' plotted. . So [['S'], ['I'], ['R']] or ['SIR'] will result in 3 plots, one with just 'S', one with just 'I' and one with just 'R'

while [['S', 'I'], ['R']] or ['SI', 'R'] will result in 2 plots, one with both 'S' and 'I' and one with just 'R'.

Defaults to the possible_statuses

ts_list list of timeseries objects (default None)
If multiple time series have been added, we might want to plot only some of them. This says which ones to plot. The simulation is always included.
nodelist list (default None)
which nodes should be included in the network plot. By default this is the entire network. This also determines which nodes are on top of each other (particularly if status_order is False).
status_order list of statuses default False
Each status will appear on top of all later statuses. If list empty or False, will ignore. Any statuses not appearing in list will simply be below those on the list and will not have priority by status.
timelabel string (default ‘$t$’)
the horizontal label to be used on the time series plots
pos dict (default None)
overrides self.pos for this display (but does not overwrite self.pos. Use set_pos if you want to do this)
statuses_to_plot list of statuses to plot.
If given, then the other nodes will be left invisible when plotting but I think this requires networkx v2.3 or later.
**nx_kwargs
any networkx keyword arguments to go into the network plot.