关于这个问题,Display different time elements at different speeds in gganimate,假设我有一个MWE,它使用ggplot2
和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)
请注意,它使用来自{frame_title}
元素的月份进行标记,该月份与transition_time
中的值相对应,在这种情况下为月份。有没有办法在标签中引用其他变量?例如,假设有两个新列number
和color
。 number
列仅是月份数,因此显示的第一个月为1,第二个月为2,依此类推。 color
将只是不同的颜色。关键是它们每个都映射到Month
。如何在labs
中引用这些其他变量?