Hi all, Just thought I'd share something I discovered last night. I was interested in creating animations consisting of a series of plots and after finding very little in the usual sources regarding animation in R directly, and disliking the imagemagick method described here (http://tolstoy.newcastle.edu.au/R/help/05/10/13297.html), I discovered that if one exports the plots to a multipage pdf, it is relatively trivial to then use the pdf2swf command in SWFTools (http://www.swftools.org/download.html; mac install instructions here: http://9mmedia.com/blog/?p=7). pdf2swf seems to generate swf animations with a slow frame rate, but you can increase the framerate using 'swfcombine -r 30 --dummy myslow.swf -o myfast.swf', where the value passed to -r is the framerate. Unfortunately, this method seems to have limitations with regards to the number of plots it can convert. For example, on my system (17" macbook pro, 2.33GHz, 2GB ram, OSX 10.4.10, R 2.5.1) the maximum number of single point plots I can do is about 5400 (i.e. for(i in 1:5400) plot(runif(1),ylim=c(0,1)) ). Complexity of the plots might matter as well, but I only have rather convoluted examples of this. Also, pdf2swf throws up a lot of errors ('ERROR Internal error: drawChar.render!=beginString.render'), the origin of which I know not, that might be slowing things down. Now, if only someone could wrap this process into a single R command (I'm a little too newb to do this myself I think). Mike -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein
SWF animation method
6 messages · bryan rasmussen, (Ted Harding), Romain Francois +2 more
I suppose what is really wanted is a way to associate a the parts of a graph with a timeline a la gapminder. Cheers, Bryan Rasmussen
On 8/8/07, Mike Lawrence <Mike.Lawrence at dal.ca> wrote:
Hi all, Just thought I'd share something I discovered last night. I was interested in creating animations consisting of a series of plots and after finding very little in the usual sources regarding animation in R directly, and disliking the imagemagick method described here (http://tolstoy.newcastle.edu.au/R/help/05/10/13297.html), I discovered that if one exports the plots to a multipage pdf, it is relatively trivial to then use the pdf2swf command in SWFTools (http://www.swftools.org/download.html; mac install instructions here: http://9mmedia.com/blog/?p=7). pdf2swf seems to generate swf animations with a slow frame rate, but you can increase the framerate using 'swfcombine -r 30 --dummy myslow.swf -o myfast.swf', where the value passed to -r is the framerate. Unfortunately, this method seems to have limitations with regards to the number of plots it can convert. For example, on my system (17" macbook pro, 2.33GHz, 2GB ram, OSX 10.4.10, R 2.5.1) the maximum number of single point plots I can do is about 5400 (i.e. for(i in 1:5400) plot(runif(1),ylim=c(0,1)) ). Complexity of the plots might matter as well, but I only have rather convoluted examples of this. Also, pdf2swf throws up a lot of errors ('ERROR Internal error: drawChar.render!=beginString.render'), the origin of which I know not, that might be slowing things down. Now, if only someone could wrap this process into a single R command (I'm a little too newb to do this myself I think). Mike -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
On 08-Aug-07 13:52:59, Mike Lawrence wrote:
Hi all, Just thought I'd share something I discovered last night. I was interested in creating animations consisting of a series of plots and after finding very little in the usual sources regarding animation in R directly, and disliking the imagemagick method described here (http://tolstoy.newcastle.edu.au/R/help/05/10/13297.html), I discovered that if one exports the plots to a multipage pdf, it is relatively trivial to then use the pdf2swf command in SWFTools (http://www.swftools.org/download.html; mac install instructions here: http://9mmedia.com/blog/?p=7).
Thanks so much for sharing your discovery, Mike! Out of the blue! (Unexpected bonus for being on the R list). Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 08-Aug-07 Time: 15:25:44 ------------------------------ XFMail ------------------------------
Hello Mike, You might want to give "mencoder" a try. It usually comes with mplayer. I did play with it a while ago and was fairly happy with the results. Basically, the idea was to create many jpg files somewhere, which is not too hard using the %03d substitution described in ?jpeg. The rest is described here: http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html Cheers, Romain PS: You might find some links in this (not really maintained) webpage: http://addictedtor.free.fr/movies/
Mike Lawrence wrote:
Hi all, Just thought I'd share something I discovered last night. I was interested in creating animations consisting of a series of plots and after finding very little in the usual sources regarding animation in R directly, and disliking the imagemagick method described here(http://tolstoy.newcastle.edu.au/R/help/05/10/13297.html), I discovered that if one exports the plots to a multipage pdf, it is relatively trivial to then use the pdf2swf command in SWFTools (http://www.swftools.org/download.html; mac install instructions here: http://9mmedia.com/blog/?p=7). pdf2swf seems to generate swf animations with a slow frame rate, but you can increase the framerate using 'swfcombine -r 30 --dummy myslow.swf -o myfast.swf', where the value passed to -r is the framerate. Unfortunately, this method seems to have limitations with regards to the number of plots it can convert. For example, on my system (17" macbook pro, 2.33GHz, 2GB ram, OSX 10.4.10, R 2.5.1) the maximum number of single point plots I can do is about 5400 (i.e. for(i in 1:5400) plot(runif(1),ylim=c(0,1)) ). Complexity of the plots might matter as well, but I only have rather convoluted examples of this. Also, pdf2swf throws up a lot of errors ('ERROR Internal error: drawChar.render!=beginString.render'), the origin of which I know not, that might be slowing things down. Now, if only someone could wrap this process into a single R command (I'm a little too newb to do this myself I think). Mike -- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein
Mango Solutions data analysis that delivers Tel: +44(0) 1249 467 467 Fax: +44(0) 1249 467 468 Mob: +44(0) 7813 526 123
Also, I've used ImageMagick's convert utility to make animated gifs. Generate a series of files (I used png) and then convert -delay 50 -page +0+0 im01.png -page +0+0 im01.png -page +0+0 im01.png -loop 0 mov.gif Max
-----Original Message----- From: r-devel-bounces at r-project.org
[mailto:r-devel-bounces at r-project.org] On Behalf Of Romain Francois
Sent: Wednesday, August 08, 2007 11:11 AM To: Mike Lawrence Cc: r-devel at r-project.org; John Christie Subject: Re: [Rd] SWF animation method Hello Mike, You might want to give "mencoder" a try. It usually comes with
mplayer.
I did play with it a while ago and was fairly happy with the results. Basically, the idea was to create many jpg files somewhere, which is
not
too hard using the %03d substitution described in ?jpeg. The rest is described here: http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html Cheers, Romain PS: You might find some links in this (not really maintained) webpage:
----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}
Thanks to Max & Romain for noting alternative methods. As mentioned in my original post, I've tried the png->imagemagick- >gif solution and was displeased with quality of the results (using default quality values at least). Additionally, I disliked the idea (shared with the menconder method) that part of the process involved the creation of a large number of intermediary files which would then have to be deleted at some point. I know 'rm *.png' is as easy as 'rm mypdf.pdf', but the difference in forgetting to do this, from the perspective of gui file browsing at least, is significant. Mike
On 8-Aug-07, at 12:20 PM, Kuhn, Max wrote:
Also, I've used ImageMagick's convert utility to make animated gifs. Generate a series of files (I used png) and then convert -delay 50 -page +0+0 im01.png -page +0+0 im01.png -page +0+0 im01.png -loop 0 mov.gif Max
-----Original Message----- From: r-devel-bounces at r-project.org
[mailto:r-devel-bounces at r-project.org] On Behalf Of Romain Francois
Sent: Wednesday, August 08, 2007 11:11 AM To: Mike Lawrence Cc: r-devel at r-project.org; John Christie Subject: Re: [Rd] SWF animation method Hello Mike, You might want to give "mencoder" a try. It usually comes with
mplayer.
I did play with it a while ago and was fairly happy with the results. Basically, the idea was to create many jpg files somewhere, which is
not
too hard using the %03d substitution described in ?jpeg. The rest is described here: http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html Cheers, Romain PS: You might find some links in this (not really maintained) webpage:
---------------------------------------------------------------------- LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-- Mike Lawrence Graduate Student, Department of Psychology, Dalhousie University Website: http://memetic.ca Public calendar: http://icalx.com/public/informavore/Public "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein