This transition allows you to let data gradually appear, based on a given
time dimension. In contrast to e.g.
calculates intermediary values at exact positions instead of coercing raw
values into the closest frame. It further keeps old data for path and polygon
type layers so that they are gradually build up instead of being a set of
disconnected segments as will happen when using
transition_reveal(along, range = NULL, keep_last = TRUE, id)
An unquoted expression giving the dimension to tween along. For
a gradually revealing time series this should be set to the same as the
The time range to animate. If
For non-path/polygon layers should the last row be kept for subsequent frames.
transition_along makes the following variables available for string
literal interpretation, in addition to the general ones provided by
frame_along gives the position on the along-dimension that the current frame corresponds to
transition_reveal uses the group aesthetic of each layer to identify
which rows in the input data correspond to the same graphic element and will
therefore define a a whole to be revealed over the animation.
The group aesthetic, if not set, will be calculated from the interaction of all
discrete aesthetics in the layer (excluding
label), so it is often better
to set it explicetly when animating, to make sure your data is interpreted in
the right way. If the group aesthetic is not set, and no discrete aesthetics
exists then all rows will have the same group.
It is possible to use variables calculated by the statistic to define the
transition. Simply inclose the variable in
stat() in the same way as when
using computed variables in aesthetics.
anim <- ggplot(airquality, aes(Day, Temp, group = Month)) + geom_line() + transition_reveal(Day) # Non-paths will only show the current position, not the history anim1 <- ggplot(airquality, aes(Day, Temp, group = Month)) + geom_line() + geom_point(colour = 'red', size = 3) + transition_reveal(Day) # Points can be kept by giving them a unique group and set `keep = TRUE` (the # default) anim2 <- ggplot(airquality, aes(Day, Temp, group = Month)) + geom_line() + geom_point(aes(group = seq_along(Day))) + geom_point(colour = 'red', size = 3) + transition_reveal(Day)