GeomHourglass {gghourglass} | R Documentation |
Add an 'hourglass' layer to a ggplot
Description
geom_hourglass()
takes a continuous datetime object, splits in in discrete dates and
time of day with stat_hourglass()
. This geometry is a wrapper
to add it as a layer to a ggplot. GeomHourglass
is a ggproto object inheriting from
?ggplot2::GeomPoint
. It should not be used directly. Instead call geom_hourglass()
.
Usage
GeomHourglass
geom_hourglass(
mapping = NULL,
data = NULL,
stat = "hourglass",
position = "identity",
na.rm = FALSE,
show.legend = NA,
hour_center = 0,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. If |
stat |
Can be used to overwrite the default connection between |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
hour_center |
The hour at which the time of day is centred. Default is 0, meaning midnight. -12 centres around noon of the preceding day, +12 centres around noon of the next day. |
inherit.aes |
If |
... |
Arguments passed to geometry. |
Format
An object of class GeomHourglass
(inherits from GeomPoint
, Geom
, ggproto
, gg
) of length 3.
Value
Returns a ggplot2::layer()
which can be added to a ggplot2::ggplot()
Author(s)
Pepijn de Vries
Examples
library(ggplot2)
data(bats)
monitoring <- attr(bats, "monitoring")
ggplot(subset(bats, format(RECDATETIME, "%Y") == "2019"),
aes(x = RECDATETIME, col = SPECDESCSCI)) +
geom_hourglass()
ggplot(dplyr::mutate(bats, YEAR = format(RECDATETIME, "%Y")),
aes(x = RECDATETIME, col = SPECDESCSCI)) +
geom_hourglass() +
facet_wrap(~YEAR, scales = "free_x")