Dear R-users,

        I would like to place two 3D plots side-by-side in a rgl-setting. It 
would nice to have something like "par(mfrow=c(1,2))" for basic plots, or an 
array framework for wireframe(lattice) (see example below). I only managed to 
overlap two persp3d plots.
My final idea would be to animate both surfaces using play3d(rgl).

Thanks in advance for any help.

Best,
Carlo Giovanni Camarda


# simple datasets
x <- seq(-10, 10, length= 30)
y <- x
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z1 <- outer(x, y, f)
z1[is.na(z1)] <- 1
z2 <- matrix(outer(1:30, 1:30)/200, 30, 30)

# simple persp
par(mfrow=c(1,2))
persp(x, y, z1)
persp(x, y, z2)

# wireframe
library(lattice)
grid. <- expand.grid(list(x=x,y=y,name=c("Z1", "Z2")))
grid.$Z <- c(c(z1), c(z2))
wireframe(Z ~ x * y | name, data = grid.)

# single plot
library(rgl)
persp3d(x, y, z1)
persp3d(x, y, z2)

# overlapping plots
persp3d(x,y,z1, color="#CCCCFF", front="lines") 
persp3d(x,y,z2, col="red", add=TRUE) 
play3d(spin3d(axis=c(0,0,1), rpm=10), duration=5)



-----------------------------------------------------
Dr. Carlo Giovanni Camarda
Research Scientist
Max Planck Institute for Demographic Research
Laboratory of Statistical Demography
Konrad-Zuse-Straße 1
18057 Rostock - Germany
Phone: +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
cama...@demogr.mpg.de
http://www.demogr.mpg.de/en/staff/camarda/default.htm
-----------------------------------------------------





----------
This mail has been sent through the MPI for Demographic ...{{dropped:10}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to