升级到 R v4 后如何使 gganimate 工作?

How to make gganimate work after upgrade to R v4?

我刚刚升级到 R 4.0.0 (Mac)。现在 gganimate 不起作用,如何解决这个问题超出了我的知识库。

作为reprex,我简单复制了gganimate帮助部分的第一个例子:

anim <- ggplot(mtcars, aes(mpg, disp)) +
  transition_states(gear, transition_length = 2, state_length = 1) +
  enter_fade() +
  exit_fade()

anim

结果是工作目录中有 100 个 png 文件,但没有动画 - 不是作为保存的文件,也不是在 RStudio 查看器中 window。

也没有生成错误消息。

有什么帮助吗?

只需在 ggplot 调用后添加 geom_point()。以下代码

anim <- ggplot(mtcars, aes(mpg, disp)) +
  geom_point(aes(color=gear))+
  transition_states(gear, transition_length = 2, state_length = 1) +
  enter_fade() +
  exit_fade()

animate(anim , renderer = gifski_renderer())

生成此输出: