Use this if you are using igraph from R
plot.sir {igraph} | R Documentation |
This function can conveniently plot the results of multiple SIR model simulations.
## S3 method for class 'sir'
plot(
x,
comp = c("NI", "NS", "NR"),
median = TRUE,
quantiles = c(0.1, 0.9),
color = NULL,
median_color = NULL,
quantile_color = NULL,
lwd.median = 2,
lwd.quantile = 2,
lty.quantile = 3,
xlim = NULL,
ylim = NULL,
xlab = "Time",
ylab = NULL,
...
)
x |
The output of the SIR simulation, coming from the |
comp |
Character scalar, which component to plot. Either ‘NI’ (infected, default), ‘NS’ (susceptible) or ‘NR’ (recovered). |
median |
Logical scalar, whether to plot the (binned) median. |
quantiles |
A vector of (binned) quantiles to plot. |
color |
Color of the individual simulation curves. |
median_color |
Color of the median curve. |
quantile_color |
Color(s) of the quantile curves. (It is recycled if needed and non-needed entries are ignored if too long.) |
lwd.median |
Line width of the median. |
lwd.quantile |
Line width of the quantile curves. |
lty.quantile |
Line type of the quantile curves. |
xlim |
The x limits, a two-element numeric vector. If |
ylim |
The y limits, a two-element numeric vector. If |
xlab |
The x label. |
ylab |
The y label. If |
... |
Additional arguments are passed to |
The number of susceptible/infected/recovered individuals is plotted over time, for multiple simulations.
Nothing.
Eric Kolaczyk (http://math.bu.edu/people/kolaczyk/) and Gabor Csardi csardi.gabor@gmail.com.
Bailey, Norman T. J. (1975). The mathematical theory of infectious diseases and its applications (2nd ed.). London: Griffin.
sir
for running the actual simulation.
g <- sample_gnm(100, 100)
sm <- sir(g, beta=5, gamma=1)
plot(sm)