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
?