gg_days {LightLogR} | R Documentation |
Create a simple datetime plot of light logger data, faceted by group
Description
gg_days()
will create a simple ggplot along the timeline. The result can
further be manipulated like any ggplot. This will be sensible to refine
styling or guides. Through the x.axis.limits
arguments, the plot can be
much refined to align several groups of differing datetime ranges. It uses
the Datetime_limits()
function to calculate the limits of the x-axis.
Another notable functions that are used are Datetime_breaks()
to calculate
the breaks of the x-axis.
Usage
gg_days(
dataset,
x.axis = Datetime,
y.axis = MEDI,
aes_col = NULL,
aes_fill = NULL,
group = NULL,
geom = "line",
scales = c("free_x", "free_y", "fixed", "free"),
x.axis.breaks = Datetime_breaks,
y.axis.breaks = c(-10^(5:0), 0, 10^(0:5)),
y.scale = "symlog",
y.scale.sc = FALSE,
x.axis.label = "Datetime",
y.axis.label = "Illuminance (lx, MEDI)",
x.axis.limits = Datetime_limits,
x.axis.format = "%a %D",
title = NULL,
subtitle = NULL,
interactive = FALSE,
facetting = TRUE,
jco_color = FALSE,
...
)
Arguments
dataset |
A light logger dataset. Expects a |
x.axis , y.axis |
column name that contains the datetime (x, defaults to
|
aes_col , aes_fill |
optional input that defines separate sets and colors
or fills them. Expects anything that works with the layer data
|
group |
Optional column name that defines separate sets. Useful for
certain geoms like |
geom |
What geom should be used for visualization? Expects a
|
scales |
For |
x.axis.breaks |
The (major) breaks of the x-axis. Defaults to
|
y.axis.breaks |
Where should breaks occur on the y.axis? Expects a
|
y.scale |
How should the y-axis be scaled?
|
y.scale.sc |
|
x.axis.label , y.axis.label |
labels for the x- and y-axis. Expects a
|
x.axis.limits |
The limits of the x-axis. Defaults to
|
x.axis.format |
The format of the x-axis labels. Defaults to |
title |
Plot title. Expects a |
subtitle |
Plot subtitle. Expects a |
interactive |
Should the plot be interactive? Expects a |
facetting |
Should an automated facet by grouping be applied? Default is
|
jco_color |
Should the |
... |
Other options that get passed to the main geom function. Can be used to adjust to adjust size, linewidth, or linetype. |
Details
The default scaling of the y-axis is a symlog
scale, which is a logarithmic
scale that only starts scaling after a given threshold (default = 0). This
enables values of 0 in the plot, which are common in light logger data, and
even enables negative values, which might be sensible for non-light data. See
symlog_trans()
for details on tweaking this scale. The scale can also be
changed to a normal or logarithmic scale - see the y.scale argument for more.
Value
A ggplot object
Examples
dataset <-
sample.data.environment %>%
aggregate_Datetime(unit = "5 mins")
dataset %>% gg_days()
#restrict the x-axis to 3 days
dataset %>%
gg_days(
x.axis.limits = \(x) Datetime_limits(x, length = lubridate::ddays(3))
)