stat_ld_annotations | R Documentation |
This function is used to show light and dark (L and D) phases as boxes on top a plot.
stat_ld_annotations(mapping = NULL, data = NULL, position = "identity", ld_colours = c("white", "black"), ypos = "bottom", height = 0.03, period = hours(24), phase = 0, l_duration = hours(12), outline = "black", x_limits = c(NA, NA), ..., na.rm = FALSE, show.legend = FALSE, inherit.aes = TRUE)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
ld_colours |
character vector of length two setting the
colours for light and dark phases, respectively.
The default is |
ypos |
position and height of the annotation on the y axis.
It can be either |
height |
relative height of the rectangles. The default is 3 percent (0.03). |
period, phase, l_duration |
period, phase and duration of the L phase (in seconds) of the LD cycle. |
outline |
colour of the border of the rectangles. A value of |
x_limits |
numerical vector of length 2 for the start and end of the annotations (in seconds).
The default, |
... |
Other arguments passed on to |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
The relevant rethomic tutorial section
ggetho to generate a plot object
Other layers: geom_peak
,
stat_bar_tile_etho
,
stat_pop_etho
library(behavr) # We start by making a to dataset with 20 animals metadata <- data.frame(id = sprintf("toy_experiment | %02d", 1:20), condition = c("A", "B")) dt <- toy_activity_data(metadata, 3) # We build a plot object pl <- ggetho(dt, aes(y = asleep)) + stat_pop_etho() pl + stat_ld_annotations() # We can also put the annotations in the background: pl <- ggetho(dt, aes(y = asleep)) + stat_ld_annotations(outline = NA) + stat_pop_etho() pl # Different colours (e.g. DD) pl + stat_ld_annotations(ld_colour = c("grey", "black")) # Shorter period pl + stat_ld_annotations(period = hours(22), phase = hours(3)) # On a tile plot: pl <- ggetho(dt, aes(z = asleep)) + stat_tile_etho() pl + stat_ld_annotations()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.