【发布时间】:2021-01-03 18:02:38
【问题描述】:
目标
使用开始/停止/暂停按钮控制动画。
问题
animation 包可以使用 saveHTML() 函数 (example here) 将创建的动画保存为 HTML 页面。但它需要“expr = 要评估的 R 表达式以创建图像序列”作为第一个参数。
但是,gganimate 创建了一个gganim 对象,我似乎找不到可以将动画保存为带有按钮的 HTML 页面的函数。可用的 anim_save() 函数不保存为 HTML。有解决办法吗?
动画示例代码
如果您有任何想法,请分享。供您参考,我将其网站上的gganimate 代码放在下面。
library(ggplot2)
library(gganimate)
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')
【问题讨论】: