将gganimate动画另存为mp4文件

时间:2018-11-10 17:14:26

标签: gganimate

是否可以将用ffmmeg_rendererav_renderer制作的电影另存为文件?我总是将主题作为数据嵌入到html文件中。

2 个答案:

答案 0 :(得分:1)

由于您没有provide a reproducible example

p <- ggplot(airquality, aes(Day, Temp)) + 
    geom_line(size = 2, colour = 'steelblue') + 
    transition_states(Month, 4, 1) + 
    shadow_mark(size = 1, colour = 'grey')
a <- animate(p, renderer = ffmpeg_renderer())

anim_save("animation.mp4", a)

答案 1 :(得分:0)

使用@Roman中的示例,我将改用library("av")

p <- ggplot(airquality, aes(Day, Temp)) + 
    geom_line(size = 2, colour = 'steelblue') + 
    transition_states(Month, 4, 1) + 
    shadow_mark(size = 1, colour = 'grey')

b <- animate(p, duration = 20, fps = 20, renderer = av_renderer())
anim_save("output.mp4", b)