Skip to contents

[Experimental] A custom ggplot2 extension to shade areas in a plot according to provided light hours. It shades from lights off to lights on. Usage through geom_lights() or stat_ligths()

Usage

StatLights

Format

An object of class StatLights (inherits from Stat, ggproto, gg) of length 3.

Arguments

lights_on_hour

An integer representing the hour of the day (0-23) when the lights turn on.

lights_off_hour

An integer representing the hour of the day (0-23) when the lights turn off.

fill

A string representing the color of the shading.

alpha

A numeric representing the transparency of the shading, between 0 (transparent) and 1 (opaque).

Value

A ggplot2 layer to be added to a ggplot object.

Examples

if (FALSE) { # \dontrun{
ggplot(df, aes(x = Pi_Time, y = Pellet_Count)) +
  stat_lights(fill = "grey80", alpha = 0.5, lights_on_hour = 7, lights_off_hour = 19) +
  geom_line()

} # }