小编Ros*_*rio的帖子

gganimate 返回 .png 文件,但没有动画对象

我正在尝试创建一个动画来向学生展示如何用动画表示数据。运行下面的代码

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

    animate(anim)
Run Code Online (Sandbox Code Playgroud)

我期待预览窗口上的动画和 gif 图像的创建。

相反,我得到的是工作目录中的 100 个 .png 文件,但没有别的。图片是正确的,是动画的帧,只是没有被函数拼凑起来。特别是我得到了 100 个元素,其中我在这里显示了第一个元素:这个列表

  [1] "./gganim_plot0001.png" "./gganim_plot0002.png" "./gganim_plot0003.png" 
  [4] "./gganim_plot0004.png" "./gganim_plot0005.png" "./gganim_plot0006.png"
  [7] "./gganim_plot0007.png" "./gganim_plot0008.png" "./gganim_plot0009.png"
 [10] "./gganim_plot0010.png" "./gganim_plot0011.png" "./gganim_plot0012.png"...
Run Code Online (Sandbox Code Playgroud)

    attr(,"frame_vars")
    frame nframes progress transitioning previous_state closest_state
1       1     100     0.01         FALSE              3             3
2       2     100     0.02         FALSE              3             3
3       3     100     0.03         FALSE              3             3
Run Code Online (Sandbox Code Playgroud)

next_state
1 …
Run Code Online (Sandbox Code Playgroud)

rendering ggplot2 gganimate

8
推荐指数
1
解决办法
3169
查看次数

标签 统计

gganimate ×1

ggplot2 ×1

rendering ×1