stat function to wrangle data for geom_hourglass.Splits mapped x or y aesthetic from a continuous datetime into
discrete date values on the mapped axis. The hour of day is mapped to
the opposite axis.
StatHourglassstat_hourglass(
mapping = NULL,
data = NULL,
geom = "hourglass",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
hour_center = 0,
na.rm = FALSE,
...
)
Returns a ggplot2::layer() which can be added to a ggplot2::ggplot()
An object of class StatHourglass (inherits from Stat, ggproto, gg) of length 7.
Set of aesthetic mappings created by ggplot2::aes(). If
specified and inherit.aes = TRUE (the default), it is combined with the
default mapping at the top level of the plot. You must supply mapping if
there is no plot mapping. The hourglass stat and geom requires either
the x axis or the y axis to be mapped. The mapped aesthetic will show
the date of the variable, whereas the opposite axis will show the time of day.
The data to be displayed in this layer. If NULL, the default,
the data is inherited from the plot data as specified in the call to
ggplot2::ggplot(). Otherwise, a data.frame, or other object, will override
the plot data. All objects will be fortified to produce a data frame.
See ggplot2::fortify() for which variables will be created. The data should
contain a column with datetime values (e.g., ?POSIXct)
Can be used to overwrite the default connection between stat_hourglass
and [geom_hourglass].
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 position argument accepts the following:
The result of calling a position function, such as position_jitter().
This method allows for passing extra arguments to the position.
A string naming the position adjustment. To give the position as a
string, strip the function name of the position_ prefix. For example,
to use position_jitter(), give the position as "jitter".
For more information and other ways to specify the position, see the layer position documentation.
logical. Should this layer be included in the legends?
NA, the default, includes if any aesthetics are mapped.
FALSE never includes, and TRUE always includes.
It can also be a named logical vector to finely select the aesthetics to
display.
If FALSE, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. borders().
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.
If FALSE, the default, missing values are removed with a warning.
If TRUE, missing values are silently removed.
Arguments passed as extra params to ggplot2::layer()
Pepijn de Vries