plot_paths: Plot epidemic paths

Description Usage Arguments Value

View source: R/plotting-functions.R

Description

Plot epidemic paths

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_paths(
  paths_data,
  y_var = n_infected,
  n_max = 200,
  tlim = NA,
  highlight_path_id = NA,
  show_hist = TRUE,
  show_extinct = TRUE,
  smooth_data = NULL,
  extinct_color = "red",
  n_bins = 20
)

Arguments

paths_data

A data.frame, with at least the columns id_sim, time, and a quoted variable passed as yvar.

y_var

Column in paths_data to use as y-variable.

n_max

An integer. Maximum number of paths to display. Useful to avoid graphs that are too crowded.

tlim

A scalar.

highlight_path_id

A subset of values in column id_sim of input paths_data that will be highlighted (black and thicker). If the values provided are not found in column id_sim, no path will be highlighted.

show_hist

A logical scalar. If TRUE, show the distribution of paths at the right-end of the plot. In this case, the output will be a ggarrange object, rather than a ggplot object.

show_extinct

A logical scalar. Show extinct paths along with non-extinct ones.

smooth_data

A data.frame, with at least the columns time, n_infected, and n_infectious. If given, will be superposed on top of the paths plot.

extinct_color

A color value understood by ggplot. This will be the colour of paths that went extinct before the end of the simulation.

n_bins

An integer scalar. Number of bins in the histogram panel.

Value

A plot. If show_hist = TRUE (default), the output will be a ggarrange object showing both the paths, and a histogram of the level at which they terminate. Otherwise the output will be a ggplot object showing only the paths.


pspc-data-science/branchsim documentation built on Jan. 19, 2021, 10:10 a.m.