【问题标题】:How to make gganimate work after upgrade to R v4?升级到 R v4 后如何使 gganimate 工作?
【发布时间】:2020-08-24 00:02:39
【问题描述】:

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

作为代表,我只是复制了 gganimate 帮助部分中的第一个示例:

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

anim

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

也没有产生错误信息。

有什么帮助吗?

【问题讨论】:

标签: r gganimate


【解决方案1】:

只需在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())

产生这个输出:

【讨论】:

  • 天啊!猜猜我草率地剪切和粘贴了一小段。 ?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-03
  • 2020-09-14
  • 2014-09-29
  • 1970-01-01
  • 2022-11-17
  • 2018-08-31
  • 2019-01-30
相关资源
最近更新 更多