[R] persp(): add second plane (second, long question)
Ben Bolker
ben at zoo.ufl.edu
Mon Mar 18 16:20:42 CET 2002
I think I may have been misled by the word "plane" -- I thought you just
wanted to superimpose a specified plane on the existing surface. It
sounds like you want a second *surface*, which is a harder proposition --
short of a complete revamping of persp(), it sounds like Mike's approach
is best. (To add another surface using trans3d(), you'd essentially have
to rewrite persp() in R code, drawing each of the appropriate polygons.)
One of the general problems is that R's graphics model is "draw and
forget", whereas for pretty 3D graphics you really want to do hidden
line/point removal, which means keeping track of all the objects you've
drawn in a 3D space.
On Mon, 18 Mar 2002, Mike Lonergan wrote:
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
318 Carr Hall bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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