gganimate plot 不显示和保存一堆 .png 的

gganimate plot not showing and saving bunch of .png's

我正在尝试从 here 复制一个关于 gganimate 的简单示例。问题很简单 ggplot 部分工作正常但是当我添加 transition_states rstudio 开始渲染然后保存一堆 gganim_plotXXXX.png 文件并且不显示预期的动画。

第一个问题显然是:我是不是做错了什么导致动画不起作用?

第二个问题是:保存一堆 .png 文件是 gganimate 的标准吗?

提前致谢

library(gganimate)

p <- ggplot(iris, aes(x = Petal.Width, y = Petal.Length)) + 
         geom_point()

anim <- p + 
  transition_states(Species,
                    transition_length = 2,
                    state_length = 1)
anim

我运行你的代码并得到这个错误:

Error in l$setup_layer(d, plot) : attempt to apply non-function

然后,我安装了 png and gifski 包并重新启动了 R-Studio。它的工作。我想,你可以试试这个。