[R] HOW to Create Movies with R with repeated plot()?

Martyn Plummer plummer at iarc.fr
Wed Jul 27 15:23:54 CEST 2005


On Wed, 2005-07-27 at 12:11 +0200, Jan Verbesselt wrote:
> Dear R-helpers,
> 
>  
> 
> Is it possible to create a type of 'movie' in R based on the output of
> several figures (e.g., jpegs) via the plot() function.  I obtained dynamic
> results with the plotting function and would like to save these as a movie
> (e.g., avi or other formats)?

You can use ImageMagick tools to convert a set of bitmap files into an
animated GIF. For example, in R, this creates 101 separate png files:

x <- seq(-1,1,length=101)
y <- x^2
png()
for (i in 1:length(y)) {
  plot(x[1:i], y[1:i], xlim=c(-1,1), ylim=c(0,1), type="l")
}
dev.off()

Then, on the command line (on Linux) this joins them together

convert -delay 10 Rplot*.png Rplot.gif
animate Rplot.gif

You can also create MNG format, but this is less widely supported.

Martyn 


-----------------------------------------------------------------------
This message and its attachments are strictly confidential. ...{{dropped}}




More information about the R-help mailing list