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

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Mar 18 16:38:05 CET 2002


For a working example of this see persp.gam() in package mgcv.  This
uses repeated calls to the persp() command to plot the gam response
surface and the +/- standard errors of the fit.

The important thing is setting the x and y limits correctly for the
first plot so that the second call the plot will fit "on top of" the
first.

Gavin

-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch] On Behalf Of Mike Lonergan
Sent: 18 March 2002 14:35
To: R help
Subject: RE: [R] persp(): add second plane (second, long question)


Nina,

There is a very crude approach that works fine for me.

> persp(z1)
> par(new=TRUE)
> persp(z2)

The plot of z2 should be superimposed on that of z1. (I think someone
here
explained to me about new=TRUE, it basically makes R think it is faced
with
a clean page and therefore not wipe it before drawing the new stuff). As
long as the x/y/zlims etc all match you should get what you need.
Hopefully.
(Though the more sophisticated solutions do sound much nicer & more
flexible).

Have fun,

Mike.

     > -----Original Message-----
     > From: owner-r-help at stat.math.ethz.ch
     > [mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Nina Lieske
     > Sent: 18 March 2002 11:51
     > To: r-help at stat.math.ethz.ch
     > Subject: RE:[R] persp(): add second plane (second, long question)
     >
     >
     > 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...
     >
     > 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?
     >
     > Thanks for your patience,
     > Nina
     >
     >
     > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
     > .-.-.-.-.-.-.-.-.-
     > 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
     > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
     > ._._._._._._._._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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