plot.incidence2 {incidence2} | R Documentation |
Plot an incidence object
Description
plot()
can be used to provide a bar plot of an incidence object. Due
to the complexities with automating plotting it is some what experimental in
nature and it may be better to use ggplot2 directly.
Usage
## S3 method for class 'incidence2'
plot(
x,
y,
width = 1,
colour_palette = vibrant,
border_colour = NA,
na_colour = "grey",
alpha = 0.7,
fill = NULL,
legend = c("right", "left", "bottom", "top", "none"),
title = NULL,
angle = 0,
size = NULL,
nrow = NULL,
n_breaks = 6L,
show_cases = FALSE,
...
)
Arguments
x |
incidence2 object. |
y |
Not used. Required for compatibility with the |
width |
Value between 0 and 1 indicating the relative size of the bars to the interval. Default 1. |
colour_palette |
The color palette to be used for the different count variables. Defaults to |
border_colour |
The color to be used for the borders of the bars. Use |
na_colour |
The colour to plot Defaults to |
alpha |
The alpha level for color transparency, with 1 being fully opaque and 0 fully transparent Defaults to 0.7. |
fill |
Which variable to colour plots by. Must be a If NULL no distinction if made for plot colours. |
legend |
Position of legend in plot. Only applied if One of "right" (default), "left", "bottom", "top" or "none". |
title |
Optional title for the graph. |
angle |
Rotation angle for text. |
size |
text size in pts. |
nrow |
Number of rows used for facetting if there are group variables present and just one count in the incidence object. Numeric values are coerced to integer via |
n_breaks |
Approximate number of breaks calculated using Numeric values are coerced to integer via Default 6L. |
show_cases |
if Normally only used for outbreaks with a small number of cases. Defaults to |
... |
Not currently used. |
Details
Faceting will occur automatically if either grouping variables or multiple counts are present.
If there are multiple count variables, each count will occupy a different row of the resulting plot.
Utilises ggplot2 so this must be installed to use.
Value
A
ggplot2::ggplot()
object.
Examples
if (requireNamespace("outbreaks", quietly = TRUE) && requireNamespace("ggplot2", quietly = TRUE)) {
data(ebola_sim_clean, package = "outbreaks")
dat <- ebola_sim_clean$linelist
inci <- incidence(dat, date_index = "date_of_onset", groups = "hospital")
plot(inci, angle = 45)
inci2 <- regroup(inci)
plot(inci2)
}