anim <- ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
shadow_mark(past = TRUE, future = TRUE, colour = 'grey') +
view_zoom(pause_length = 1, step_length = 2, nsteps = 3)
# Use pan_zoom to change the relationship between pan- and zoom movement
# Mainly zooming
anim1 <- ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
shadow_mark(past = TRUE, future = TRUE, colour = 'grey') +
view_zoom(pause_length = 1, step_length = 2, nsteps = 3, pan_zoom = -3)
# Mainly panning
anim2 <- ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
shadow_mark(past = TRUE, future = TRUE, colour = 'grey') +
view_zoom(pause_length = 1, step_length = 2, nsteps = 3, pan_zoom = -3)
Run the code above in your browser using DataLab