Learn R Programming

SimInf (version 5.0.0)

plot-methods: Plot '>SimInf_events

Description

Plot '>SimInf_events

Plot '>SimInf_model

Usage

# S4 method for SimInf_events
plot(x, frame.plot = FALSE, ...)

# S4 method for SimInf_model plot(x, legend = NULL, col = NULL, lty = NULL, lwd = 2, N = FALSE, compartments = NULL, spaghetti = FALSE, ...)

# S4 method for SEIR plot(x, col = c("blue", "orange", "red", "darkgreen"), lty = rep(1, 4), lwd = 2, ...)

# S4 method for SIR plot(x, col = c("blue", "red", "darkgreen"), lty = rep(1, 3), lwd = 2, ...)

# S4 method for SISe plot(x, col = c("blue", "red"), lty = rep(1, 2), lwd = 2, ...)

# S4 method for SISe3 plot(x, legend = expression(S[1], I[1], S[2], I[2], S[3], I[3]), col = rep(c("blue", "red"), 3), lty = rep(1:3, each = 2), lwd = 2, ...)

# S4 method for SISe3_sp plot(x, legend = expression(S[1], I[1], S[2], I[2], S[3], I[3]), col = rep(c("blue", "red"), 3), lty = rep(1:3, each = 2), lwd = 2, ...)

# S4 method for SISe_sp plot(x, col = c("blue", "red"), lty = rep(1, 2), lwd = 2, ...)

Arguments

x

The model to plot

frame.plot

Draw a frame around each plot. Default is FALSE.

...

Additional arguments affecting the plot produced.

legend

The character vector to appear in the legend. Default is to use the names of the compartments.

col

The plotting color for each compartment. Default is black.

lty

The line type for each compartment. Default is the sequence: 1=solid, 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash.

lwd

The line width for each compartment. Default is 2.

N

if TRUE, the average number of individuals in each compartment, else the proportion of individuals in each compartment. Default is FALSE.

compartments

Character vector with the compartments in the model to include in the plot. Default is NULL i.e. include all compartments in the model.

spaghetti

Plot one line for each node. Default is FALSE.

Examples

Run this code
# NOT RUN {
## Create an 'SIR' model with 10 nodes and initialise
## it with 99 susceptible individuals and one infected
## individual. Let the model run over 100 days.
model <- SIR(u0 = data.frame(S = rep(99, 10),
                             I = rep(1, 10),
                             R = rep(0, 10)),
             tspan = 1:100,
             beta = 0.16,
             gamma = 0.077)

## Run the model and save the result.
result <- run(model, threads = 1, seed = 1)

## Plot the proportion of susceptible, infected and recovered
## individuals.
plot(result)

## Plot the number of susceptible, infected and recovered
## individuals.
plot(result, N = TRUE)

## Plot the number of infected individuals.
plot(result, compartments = "I", N = TRUE)
# }

Run the code above in your browser using DataLab