ggcalendar | R Documentation |
ggcalendar calculates the necessary date components and creates a ggplot object with the correct mappings for the other cal_* components.
cal_month_border uses ggplot2::geom_segment()
to draw a border around the months.
cal_label is a wrapper around ggplot2::geom_text()
(but ggplot2::geom_label()
could be used).
ggcalendar(
data,
x = "date",
z = "O3_max_h1",
size = 0.1,
color = "white",
...,
locale = Sys.getlocale("LC_TIME")
)
cal_month_border(
size = 0.5,
lineend = "square",
linejoin = "bevel",
color = "grey5",
...
)
cal_label(
mapping = NULL,
stat = "identity",
data = NULL,
geom = "text",
position = "identity",
show.legend = FALSE,
inherit.aes = TRUE,
na.rm = TRUE,
size = 2,
color = "white",
...
)
data |
input data |
x |
date column as Date, POSIXct or Character |
z |
value columns |
size |
parameter passed on to |
color |
parameter passed on to |
... |
more options for |
locale |
locale string for |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
mapping |
Set of aesthetic mappings created by |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
geom |
geom used for layer. "label" could be an alternative |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
na.rm |
If |
ggplot2 object
ggplot2 layer
ggplot2 layer
library(ggplot2)
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_2010-2014.csv")
# keep only 2 years for smaller plotsize
df <-
rOstluft::read_airmo_csv(fn) %>%
dplyr::filter(starttime < lubridate::ymd(20120101)) %>%
rOstluft::resample(new_interval = "d1") %>%
rOstluft::rolf_to_openair()
ggcalendar(df, z = "PM10") +
scale_fill_viridis_c(direction = -1, option = "magma", na.value = NA)
# can be customised...
ggcalendar(df, z = "PM10") +
scale_fill_viridis_c(direction = -1, option = "magma", na.value = NA) +
cal_month_border(color = "black") +
stat_filter(aes(filter = PM10 > 50), position = position_nudge(y = 0.25),
size = 1, shape = 21, color = "white", fill = "white") +
cal_label(aes(label = round(PM10,0)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.