[R] Animating a persp plot: non-constant scaling?

Ben Bolker ben at zoo.ufl.edu
Tue Oct 23 00:05:22 CEST 2001


  The only thing that springs to mind is that there's a parameter in
Mathematica graphics that controls this, called (I believe)
SphericalGraphics.  Doesn't help that much for controlling persp, however.
  I'll also point out that I've got the LG3d (LiveGraphics3d interface)
package in slightly better shape; it's available as part of bundle
"bbmisc" from http://www.zoo.ufl.edu/bolker/R/{windows,linux}.  You might
find it useful -- it doesn't do animations (although LiveGraphics3D can),
but it is good for user-controllable display of a 3d object or surface.

  Ben Bolker

On Sun, 21 Oct 2001, Uwe Ligges wrote:

> Elliot Williams wrote:
> >
> > Hi all,
> >
> > I'm making an animation of a rotating persp plot of some data.  It's easy,
> > really:  I just plot the persp in a loop over the theta parameter, saving
> > each plot, and then chain them together with ImageMagick (as suggested on
> > Paul Johnson's R-tips page).
> >
> > But...  when you run the animation, because each graph is individually
> > re-scaled, the image is not the same size in each frame.  That is, when the
> > bounding box is facing you (theta=0), the plotted image is bigger than when
> > it's at 45 degrees to the front.
> >
> > Here's a simple example:
> >
> > thetas <- seq(0,360,10)
> > for (i in 1:36){
> >         png(paste("image", "_", i, ".png", sep = ""))
> >         persp(outer(seq(0.1,1,.01),seq(0.2,1,.01), beta), theta=thetas[i])
> >         dev.off()
> > }
> >
> > then rename the files (1 -> 01) so that they're in order
> > (is there a clever way around doing this from within R?),
>
> Yes:
>  paste("image", "_", formatC(i, width=2, flag="0"), ".png", sep = "")
>
>
> > then animate with a command similar (on Linux) to:
> >
> > (bash)$ convert -delay 10 -loop 5 image*.png animated.gif
> >
> > Then open it up with something that likes animated gifs (I use a browser).
> > See how it wobbles?  Any clues?
>
> It "wobbles" because of the "intelligent scaling" that R does.
> I think there is no easy solution for your request. What you can try is
> to set some graphical parameters, but I am afraid that wouldn't result
> in an absolute non-wobbling movie.
> Maybe ggobi or another software like that can do the trick better than
> R?
>
> Uwe Ligges
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list