I attempting to animate one line at a time using gganimate, where one line animates to completion before the next one starts.
Here is my current code:
library(gganimate)
library(reshape2)
library(ggplot2)
df <- data.frame(Index = c(1:10), a= 2*(1:10), b = 3*(1:10))
df <- melt(df, id.vars = "Index")
ggplot(df, aes(x=Index, y = value, group = variable)) +
geom_line()+
transition_reveal(Index)
This gives me the graph below, where both lines are animated simultaneously.
ggplot(transform(df, ind = 1:nrow(df)),
aes(x=Index, y = value, group = variable)) +
geom_line()+
transition_reveal(ind)