This transition allows you to map a variable in your data to a specific frame in the animation. No tweening of data will be made and the number of frames in the animation will be decided by the number of levels in the frame variable.
transition_manual(frames, ..., cumulative = FALSE)
The unquoted name of the column holding the frame membership.
Keep data from previous frames as part of the current frame data
transition_states makes the following variables available for string
literal interpretation, in addition to the general ones provided by
previous_frame The name of the last frame the animation was at
current_frame The name of the current frame
next_frame The name of the next frame in the animation
transition_manual does not link rows across data to the same graphic
element. Every frame is a discrete state and no animation between the states
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(mtcars, aes(factor(gear), mpg)) + geom_boxplot() + transition_manual(gear) # Using `cumulative = TRUE` to keep data from older frames anim2 <- ggplot(mtcars, aes(factor(gear), mpg)) + geom_boxplot() + transition_manual(gear, cumulative = TRUE) # Use `factor()` to set the order of the frames anim3 <- ggplot(mtcars, aes(factor(gear), mpg)) + geom_boxplot() + transition_manual(factor(gear, levels = c('4', '3', '5')))