我通常使用gganimate生成一堆动画,并将它们放在html中以在报表服务器上显示。 我想将所有动画组合在一起,而不是使用R为每个动画创建一个页面。
我遵循@ ThomasP85(gganimate软件包的创建者)在GitHub上针对此问题写的对此功能请求的回答:
https://github.com/thomasp85/gganimate/issues/238
使用gganimate github网站上的两个示例:
library(ggplot2)
library(gganimate)
FirstPlot <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
SecondPlot <- 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(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))
animate(list=(FirstPlot,SecondPlot ), renderer = gifski_renderer(loop = FALSE))
但到目前为止没有成功。