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

From: Earl F. Glynn <>
Date: Thu 28 Jul 2005 - 00:39:37 EST

"Jan Verbesselt" <> wrote in message news:000e01c59293$80ee5d00$ 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)?

  1. You can create animated GIFs with the caTools package.
  2. ImageMagick (clipped from R-Help) It is quite easy to do with ImageMagick (, which can be installed on most OSes. I tried this simple sequence and it worked


In R:

> for(i in 1:5) {

+ jpeg(paste("fig", i, ".jpg", sep = ""))

+ hist(rnorm(100))


+ }

Then from the command line (I tried it using Linux, though it should be the

same on any platform):

% convert -delay 50 -loop 50 fig*.jpg animated.gif

This created animated.gif, a nice animation of my sequence of files. You

can control the timing of the animation by playing with -delay and -loop.

3) TCL/TK Animation (clipped from R-Help)

The tcltk package also has ways of doing this kind of stuff:


 f <- function(){plot(rnorm(1000)); tkcmd("after", 1000,f)}


(To stop, set f <- NULL)

efg mailing list PLEASE do read the posting guide! Received on Thu Jul 28 00:53:11 2005

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