FAQ
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?

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

## Search Discussions

•  at Mar 18, 2002 at 2:34 pm ⇧
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? >
Nina
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
•  at Mar 18, 2002 at 3:20 pm ⇧
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?

Nina

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
•  at Mar 18, 2002 at 3:38 pm ⇧
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? >
Nina
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
•  at Mar 18, 2002 at 3:39 pm ⇧

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

## Related Discussions

Discussion Overview
 group r-help categories r posted Mar 18, '02 at 11:50a active Mar 18, '02 at 3:39p posts 5 users 5 website r-project.org irc #r

### 5 users in discussion

Content

People

Support

Translate

site design / logo © 2017 Grokbase