EoN.Simulation_Investigation.display¶
-
Simulation_Investigation.
display
(time, ts_plots=None, ts_list=None, nodelist=None, status_order=False, timelabel='$t$', pos=None, statuses_to_plot=None, **nx_kwargs)[source]¶ Provides a plot of the network at a specific time and (optionally) some of the time series
By default it plots the network and all time series. The time series are plotted in 3 (for SIR) or 2 (for SIS) different plots to the right of the network. There are options to control how many plots appear and which time series objects are plotted in it.
We can make the number of time series plots to the right be zero by setting ts_plots to be an empty list.
Arguments: - time float
- the time for the snapshot of the network.
- ts_plots (list of strings, defaults to
statuses_to_plot
, which defaults - to
self._possible_statuses_
)if
[]
orFalse
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
isFalse
). - 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
- 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.
Returns: - network_ax, ts_ax_list (axis, list of axises)
- The axes for the network plot and a list of all the axes for the timeseries plots
Notes :
If you only want to plot the graph, set ts_plots equal to [].
If you want S, I, and R on a single plot, set ts_plots equal to [‘SIR’]
If you only want some of the timeseries objects, set ts_list to be those (the simulation time series will always be plotted).
Examples :
To show a plot where sim is the Simulation_Investigation object simply do
sim.display() plt.show()
To save it,
sim.display() plt.savefig(filename).
If you want to do more detailed modifications of the plots, this returns the axes:
network_ax, timeseries_axes = sim.display()