[R] rgl: reproduce final state of interactive plot?

sjaffe sjaffe at riskspan.com
Thu Jul 14 19:56:38 CEST 2011


Terrific! This is great to know.

I first tried saving and restoring the entire set from par3d but this
produced some changes (eg bg) and also one must call par3d with
no.readonly=TRUE. Clearly this is the way to go if one has changed a variety
of rgl properties.  But if one has only used the mouse to rotate/scale I
discovered (by looking at the documentation of view3d) that I believe that
all one needs are userMatrix, FOV, and zoom:


## create an rgl plot, interact with it, then:
snap <- par3d( c("userMatrix", "FOV", "zoom") )

## create a new rgl plot, apply the same transformation:
par3d( snap )


This can also be used to 'snap' the current view during an interactive
session and restore it later during that same session, which could be quite
useful.

To save typing, a (trivial) pair of functions to encapsulate this:

snap.view    <- function() par3d( c("userMatrix", "FOV", "zoom") )
restore.view <- function( snap) par3d( snap )





--
View this message in context: http://r.789695.n4.nabble.com/rgl-reproduce-final-state-of-interactive-plot-tp3667866p3668272.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list