从R系列图中创建电影 [英] Creating a Movie from a Series of Plots in R

查看:160
本文介绍了从R系列图中创建电影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来创建一个电影,通过拼接在一起的几个情节,在R?

解决方案

我找到了一种使用R帮助的方法:



创建单个图像帧:

  jpeg(/ tmp / foo%02d.jpg)
for(i in 1:5){
my.plot(i)
}
dev .off()

制作影片时,首先安装 ImageMagick
然后调用下面的函数(调用convert,ImageMagick的一部分,我猜想):

  make.mov <  -  function(){
unlink(plot.mpg)
system(convert -delay 0.5 plot * .jpg plot.mpg)
}

或者尝试使用ffmpeg函数,如 article (我发现这会给出更清晰的结果):
ffmpeg -r 25 -qscale 2 -i tmp / foo%02d.jpg output.mp4



可能需要一些修补,但是一旦安装了所有东西,这似乎很简单。



当然,在任何你看到jpg或jpeg的地方,你都可以用GIF或PNG来代替你的幻想。


Is there an easy way to create a "movie" by stitching together several plots, within R?

解决方案

Here is one method I found using R help:

To create the individual image frames:

jpeg("/tmp/foo%02d.jpg")
for (i in 1:5) {
  my.plot(i)
}
dev.off()

To make the movie, first install ImageMagick. Then call the following function (which calls "convert", part of ImageMagick I suppose):

make.mov <- function(){
     unlink("plot.mpg")
     system("convert -delay 0.5 plot*.jpg plot.mpg")
}

Or try using the ffmpeg function as described in this article (I've found this gives cleaner results): ffmpeg -r 25 -qscale 2 -i tmp/foo%02d.jpg output.mp4

May require a bit of tinkering, but this seemed pretty simple once everything was installed.

Of course, anywhere you see "jpg" or "jpeg", you can substitute GIF or PNG to suit your fancy.

这篇关于从R系列图中创建电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆