[R] animation without intermediate files?

Paul Murrell p.murrell at auckland.ac.nz
Tue Jan 25 01:40:15 CET 2005


Hi


Cari G Kaufman wrote:
> Hello, 
> 
> Does anyone know how to make "movies" in R by making a sequence of plots?  
> I'd like to animate a long trajectory for exploratory purposes only,
> without creating a bunch of image files and then using another program to
> string them together.  In Splus I would do this using double.buffer()  to
> eliminate the flickering caused by replotting. For instance, with a 2-D
> trajectory in vectors x and y I would use the following:
> 
> motif()
> double.buffer("back")
> for (i in 1:length(x)) {
>   plot(x[i], y[i], xlim=range(x), ylim=range(y))
>   double.buffer("copy")
> }
> double.buffer("front")
> 
> I haven't found an equivalent function to double.buffer in R.  I tried
> playing around with dev.set() and dev.copy() but so far with no success
> (still flickers).


Double buffering is only currently an option on the Windows graphics 
device (and there it is "on" by default).  So something like ...

x <- rnorm(100)
for (i in 1:100)
   plot(1:i, x[1:i], xlim=c(0, 100), ylim=c(-4, 4), pch=16, cex=2)

is already "smooth"

Paul
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list