library(ggplot2)
library(dplyr)
library(lubridate)
## Extract monitoring periods from 'bats' data
monitoring_periods <-
attr(bats, "monitoring") |>
mutate(time_on = as_datetime(time_on),
time_off = as_datetime(time_off))
ggplot(bats, aes(x = RECDATETIME, col = SPECDESCSCI)) +
## Set background to transparent red to contrast with
## monitoring periods
theme(panel.background = element_rect(fill = "#FF000044")) +
## Annotate periods in which the detector was active with
## white rectangles
annotate_periodstates(
aes(x = start, xend = end,
y = time_on, yend = time_off),
monitoring_periods,
fill = "white") +
## plot observations
geom_hourglass(hour_center = -6)
Run the code above in your browser using DataLab