Is there an easy way to create a "movie" by stitching together several plots, within R?
相关问题
- R - Quantstart: Testing Strategy on Multiple Equit
- Using predict with svyglm
- Reshape matrix by rows
- Extract P-Values from Dunnett Test into a Table by
- split data frame into two by column value [duplica
相关文章
- How to convert summary output to a data frame?
- How to plot smoother curves in R
- Paste all possible diagonals of an n*n matrix or d
- How to create a MediaClip from RenderTargetBitmap
- ess-rdired: I get this error “no ESS process is as
- How to use doMC under Windows or alternative paral
- dyLimit for limited time in Dygraphs
- Saving state of Shiny app to be restored later
If you wrap your R script within a larger Perl/Python/etc. script, you can stitch graphs together with your favorite command-line image stitching tool.
To run your R script with a wrapper script, use the
R CMD BATCH
method.Here's a full example on making an animated GIF "movie" from an HDF5 file. The data should be an HDF Dataset of a 3 dimensional array [Nframes][Nrows][Ncolumns].
Here is one method I found using R help:
To create the individual image frames:
To make the movie, first install ImageMagick. Then call the following function (which calls "convert", part of ImageMagick I suppose):
Or try using the ffmpeg function as described in this article (I've found this gives cleaner results): ffmpeg -r 25 -qscale 2 -i tmp/foo%02d.jpg output.mp4
May require a bit of tinkering, but this seemed pretty simple once everything was installed.
Of course, anywhere you see "jpg" or "jpeg", you can substitute GIF or PNG to suit your fancy.
I'm not sure it is possible in R. I did a project once when data points from R were exported to a MySQL database and a Flex/Flash application picked up those data points and gave animated visualizations..
Take a look at either the animation package created by Yihui Xie or the EBImage bioconductor package (?animate).
I think you can do this also with the write.gif function in the caTools library. You'd have to get your graph into a multi-frame image first. I'm not sure how to do that. Anyone? Bueller?
The classic example of an animated GIF is this code which I didn't write but I did blog about some time ago:
Code credit goes to Jarek Tuszynski, PhD.