View source: R/geom_vline_year.R
geom_vline_year | R Documentation |
Determines turn of year dates based on the range of either the x or y axis of the ggplot.
geom_vline_year()
draws vertical lines at the turn of each year
geom_hline_year()
draws horizontal lines at the turn of each year
geom_vline_year(
mapping = NULL,
position = "identity",
year_break = "01-01",
break_type = c("day", "week", "isoweek", "epiweek"),
just = NULL,
...,
show.legend = NA
)
geom_hline_year(
mapping = NULL,
position = "identity",
year_break = "01-01",
break_type = c("day", "week", "isoweek", "epiweek"),
just = NULL,
...,
show.legend = NA
)
mapping |
Mapping created using |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
year_break |
String specifying the month and day ("MM-DD") or week ("W01") of the year break .
Defaults to: |
break_type |
String specifying the type of break to use. Options are:
|
just |
Numeric offset in days (justification). Shifts the lines from the year break date.
Defaults to |
... |
Other arguments passed to
|
show.legend |
logical. Should this layer be included in the legends? |
A ggplot2 layer that can be added to a plot.
geom_epicurve()
, ggplot2::geom_vline()
library(ggplot2)
set.seed(1)
plot_data_epicurve_imp <- data.frame(
date = rep(as.Date("2023-12-01") + ((0:300) * 1), times = rpois(301, 0.5))
)
# Break type day
ggplot(plot_data_epicurve_imp, aes(x = date, weight = 2)) +
geom_epicurve(date_resolution = "week") +
geom_vline_year() +
labs(title = "Epicurve Example") +
scale_y_cases_5er() +
scale_x_date(date_breaks = "4 weeks", date_labels = "W%V'%g") + # Correct ISOWeek labels week'year
theme_bw()
# Break type week
ggplot(plot_data_epicurve_imp, aes(x = date, weight = 2)) +
geom_epicurve(date_resolution = "week") +
geom_vline_year(break_type = "week") +
labs(title = "Epicurve Example") +
scale_y_cases_5er() +
scale_x_date(date_breaks = "4 weeks", date_labels = "W%V'%g") + # Correct ISOWeek labels week'year
theme_bw()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.