[R] two perspective plots in in plot
Greg Snow
Greg.Snow at intermountainmail.org
Fri Feb 9 19:11:24 CET 2007
Probably the easiest way is to use the "wireframe" function in the
lattice package. The second example in the help shows 2 surfaces (you
do need to combine the data into a single data frame).
If you really want to use the "persp" function, then you could create
the first plot, then call "par(new=TRUE)" and then do the 2nd plot, but
that would take a lot of thinking to get the axes and scales to line up
properly and make it look good.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Roland Rau
> Sent: Friday, February 09, 2007 9:01 AM
> To: r-help
> Subject: [R] two perspective plots in in plot
>
> Dear all,
>
> I would like to put two perspective plots into one plot. The
> help page for ?persp shows how one can add points and lines
> but not another perspective plot.
>
> data(volcano)
> z <- 2 * volcano # Exaggerate the relief
> x <- 10 * (1:nrow(z)) # 10 meter spacing (S to N)
> y <- 10 * (1:ncol(z)) # 10 meter spacing (E to W)
> ## Don't draw the grid lines : border = NA persp(x, y, z,
> theta = 135, phi = 30, col = "green3", scale = FALSE,
> ltheta = -120, shade = 0.75, border = NA, box = FALSE)
>
> and now I would like to include another surface. I was hoping
> for a possibility like add=TRUE such as in contour:
>
> persp(x, y, z+10, theta = 135, phi = 30, col = "red", add=TRUE)
>
> Can someone point out to me how it can be accomplished (maybe
> a function in another package)?
>
> Thank you very much,
> Roland
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
More information about the R-help
mailing list