0

Related to this question, Display different time elements at different speeds in gganimate, suppose I have this MWE that creates a plot with ggplot2 and gganimate:

library(ggplot2)
library(gganimate)
a <- ggplot(airquality, aes(Day, Temp, 
                            group = interaction(Month, Day))) +
  geom_point(color = 'red', size = 1) +
  transition_time(Month) +
  shadow_mark(colour = 'black', size = 0.75) +
  enter_fade() +
  labs(title = paste('Month: {frame_time}')) +
animate(a, nframes = 100)

Note that it labels it with the month, which comes from the {frame_title} element, which corresponds to the value in transition_time, in this case the month. Is there a way to refer to a different variable in the label? For example, say that there are two new columns, number and color. The number column is just the number of the month, so the first month that appears will be a 1, the second will be a two, and so on. The color will just be different colors. The key is that they each map to Month. How can I refer to these other variables within labs?

bill999
  • 2,147
  • 8
  • 51
  • 103
  • 2
    Duplicate of [Display different time elements at different speeds in gganimate](https://stackoverflow.com/questions/56411936/display-different-time-elements-at-different-speeds-in-gganimate) – M-- Jun 02 '19 at 20:16
  • 1
    I understand that why you asked this question. To find a workaround for the other problem. But this is what's called [XY Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). I answered your question on the other thread which also addresses this one. Cheers. – M-- Jun 02 '19 at 20:18

0 Answers0