[R] persp(): add second plane (second, long question)

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Mar 18 16:39:36 CET 2002

Nina Lieske wrote:
> Thank you for your replies so far.
> Sorry for bothering you again, but I'm still not able to get what I need as
> I don't understand all parts of the replies (just using R for easy
> things....).
> Is there a code for plane3d() like some of you sent me for points3d()? I was
> not able to get that out of the scatterplot3d package...

Well, since scatterplot3d is not designed for the usage with persp()
*and* the plane3d() function returned by scatterplot3d() is only
designed for plane (z depends linear of x and y) planes, that's simply
not possible.

Another way is to plot a plane as a grid of lines or points into an
existing plot (either persp() or scatterplot3d()), but that would need a
hughe amount of code.

> What I can do is to get the x,y and z-range for the xlim,ylim and zlim so
> that the two planes would fit the box (x and y  values are the same for both
> (1x6vectors)). And I'm able to store the z-values in two different matrices
> (6x6).
> What I did then is
> > xachse<-c(1:6)
> > yachse<-xachse
> >
> > par(bg = "white")
> >
> > trans3d <- function(x,y,z,pmat) {
> +   tmat <- t((cbind(x,y,z,1)%*% pmat))
> +   list(x=tmat[1,]/tmat[4,],y=tmat[2,]/tmat[4,])
> + }
> > pmat <- persp(xachse, yachse, betaon1.median.plot,zlim=c(2.75,3.30), theta
> = 60, phi = 20,
> +               col = "lightblue", xlab = "X", ylab = "Y", zlab = "Z",
> +               ticktype="detailed")
> This generates a plot for one sample of z-values with enough space for the
> second plane. How do I now add the second plane?

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

More information about the R-help mailing list