View source: R/annotate_daylight.R
AnnotateDaylight | R Documentation |
Annotate a ggplot (currently only plots using coord_hourglass()
is supported) with a coloured band indicating solar events, such
as sunset and sunrise.
AnnotateDaylight
annotate_daylight(
longitude = 0,
latitude = 60,
sun_prop = c("sunrise", "sunset"),
...
)
longitude , latitude |
Geographical location that will be used to calculate sunlight times. |
sun_prop |
A vector of two solar events that should be
captured by the annotation. It will be shown as a coloured band
between these two events. Default is |
... |
Passed to the list of layer parameters. |
An object of class AnnotateDaylight
(inherits from GeomPolygon
, Geom
, ggproto
, gg
) of length 6.
Returns a ggplot2::layer()
which can be added to a ggplot2::ggplot()
Pepijn de Vries
library(ggplot2)
data(bats)
monitoring <- attr(bats, "monitoring")
ggplot(subset(bats, format(RECDATETIME, "%Y") == "2018"),
aes(x = RECDATETIME, col = SPECDESCSCI)) +
annotate_daylight(monitoring$longitude[1], monitoring$latitude[1], c("sunset", "sunrise")) +
annotate_daylight(monitoring$longitude[1], monitoring$latitude[1], c("dusk", "dawn")) +
geom_hourglass()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.