This transition treats each visual element as an event in time and allows you to control the duration and enter/exit length individually for each event.
transition_events(
start,
end = NULL,
range = NULL,
enter_length = NULL,
exit_length = NULL
)
The unquoted expression giving the start and end time of
each event. If end
is NULL
the event will be treated as having no duration.
The range the animation should span. Defaults to the range of the events from they enter to they have exited.
The unquoted expression giving the length to be used for enter and exit for each event.
transition_components
makes the following variables available for string
literal interpretation, in addition to the general ones provided by
animate()
:
frame_time gives the time that the current frame corresponds to
transition_events
does not link rows across data to the same graphic
element, so elements will be defined uniquely by each row and its specific
start, end, enter and exit.
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.
Other transitions:
transition_components()
,
transition_filter()
,
transition_layers()
,
transition_manual()
,
transition_null()
,
transition_reveal()
,
transition_states()
,
transition_time()
data <- data.frame(
x = 1:10,
y = runif(10),
begin = runif(10, 1, 100),
length = runif(10, 5, 20),
enter = runif(10, 5, 10),
exit = runif(10, 5, 10)
)
anim <- ggplot(data, aes(x, y)) +
geom_col() +
transition_events(start = begin,
end = begin + length,
enter_length = enter,
exit_length = exit) +
enter_grow() +
exit_drift(x_mod = 11) +
exit_fade()