如何使用gganimate引用标签(实验室)中的其他变量

时间:2019-06-02 18:37:17

标签: r animation ggplot2 plot gganimate

关于这个问题,Display different time elements at different speeds in gganimate,假设我有一个MWE,它使用ggplot2gganimate创建了一个图:

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)

请注意,它使用来自{frame_title}元素的月份进行标记,该月份与transition_time中的值相对应,在这种情况下为月份。有没有办法在标签中引用其他变量?例如,假设有两个新列numbercolornumber列仅是月份数,因此显示的第一个月为1,第二个月为2,依此类推。 color将只是不同的颜色。关键是它们每个都映射到Month。如何在labs中引用这些其他变量?

0 个答案:

没有答案