transition_manual: Create an animation by specifying the frame membership...

Description Usage Arguments Label variables Object permanence Computed Variables See Also Examples

View source: R/transition-manual.R

Description

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.

Usage

1
transition_manual(frames, ..., cumulative = FALSE)

Arguments

frames

The unquoted name of the column holding the frame membership.

...

Additional variables

cumulative

Keep data from previous frames as part of the current frame data

Label variables

transition_states makes the following variables available for string literal interpretation, in addition to the general ones provided by animate():

Object permanence

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 is done.

Computed Variables

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.

See Also

Other transitions: transition_components(), transition_events(), transition_filter(), transition_layers(), transition_null(), transition_reveal(), transition_states(), transition_time()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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')))

gganimate documentation built on Oct. 23, 2020, 8:04 p.m.