[R] Animation for pers3d
murdoch.duncan at gmail.com
Tue Apr 5 13:24:48 CEST 2011
On 11-04-05 5:43 AM, Grigory Alexandrovich wrote:
> Hello all,
> I use persp3d from the rgl-package to plot a sruface. The typical call
> is persp3d(x, y, z)
> With cooridinate-vectros x, y and a function-values matrix z.
> Now I have different z's, say z_1,...,z_n
> Is it possible to generate an animation from a sequence of such calls,
> for different z's?
> I would like to see how the surface is beeing changed in the time.
Yes, you can do animations. See example(persp3d) for one that changes
the viewpoint. If you want to change the content of the plot, save the
result of persp3d() on the first call, e.g.
objs <- persp3d( ... )
surface <- objs["surface"]
then delete and re-plot the "surface" element:
# compute new x y z
surface <- surface3d(x, y, z)
If the scale changes during the animation it's likely to look ugly, so
set the limits in the persp3d call (or turn off the axes).
More information about the R-help