gganimate to sequentially show lines using discrete variable

Hi! I'm new to gganimate. I would like to create a plot that transitions through the variable mapped in the colour aesthetic. More concretely, given this plot:

library(tidyverse)
set.seed(123)
random_data <- tibble(m1 = sample(10:20, 10),
                      m2 = sample(100:200, 10),
                      m3 = sample(1000:2000, 10),
                      x = 1:10) %>%
  pivot_longer(-x, names_to = "method")
ggplot(random_data, aes(x, value, color = method)) +
  geom_line()

I would like the lines to appear step by step, something like this: https://twitter.com/jburnmurdoch/status/1347200811303055364?s=21

Is it possible?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.