View source: R/transition-events.R
transition_events | R Documentation |
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
)
start, end |
The unquoted expression giving the start and end time of
each event. If |
range |
The range the animation should span. Defaults to the range of the events from they enter to they have exited. |
enter_length, exit_length |
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.