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

From: Martyn Plummer <plummer_at_iarc.fr>
Date: Wed 27 Jul 2005 - 23:23:54 EST

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}}

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 27 23:33:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:03 EST