利用Github 上包的 wiki 中的这个示例:
airq <- airquality
airq$Month <- format(ISOdate(2004,1:12,1),"%B")[airq$Month]
ggplot(airq, aes(Day, Temp, group = Month)) +
geom_line() +
geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') +
geom_point(size = 2) +
geom_text(aes(x = 31.1, label = Month), hjust = 0) +
transition_reveal(Month, Day) +
coord_cartesian(clip = 'off') +
labs(title = 'Temperature in New York', y = 'Temperature (°F)') +
theme_minimal() +
theme(plot.margin = margin(5.5, 40, 5.5, 5.5))
产生类似的东西:
我想知道是否有任何方法可以在特定点定义动画中的暂停。例如,在第 10 天,然后是第 20 天,然后在动画结束时,再次循环之前。geom_reveal
没有可用state_length
的transition_length
参数,所以我不确定这是否可能。
编辑:包作者在推特上提到它是可能的,但我不知道他指的是什么“揭示时间”论点。