Hi

Robin Hankin wrote:
Hello everyone

I always cut-n-paste Paul's suggestions and end up learning something!

In this case, though, I have a query.

I was wondering how the second persp() call dealt with hidden line
removal,  because pieces of mesh with NA values are see-through.

If you replace xi in the code below with 10:28
and yi with 19:20, then all the pink grid
appears in front of the blue grid; I would expect the blue grid to hide some of the pink
grid.  Is there any way to enforce
hidden line removal here?


persp() just draws the mesh from "back" to "front"; a sort of brute-force hidden-line removal. R graphics has a simple "painters" model with later output overlaying previous output; so you can only draw extra stuff on the "front" of a persp() plot. If you want more sophisticated hidden-line removal you'll probably have to go to the rgl package (which does the real thing).

Paul


On May 31, 2005, at 01:14 am, Paul Murrell wrote:

Hi


[EMAIL PROTECTED] wrote:

Hello R-sters,
I'm trying to add several lines to a response surface that I've plotted
using persp().  I've tried lines() using the "trans3d" function but I've
been unsuccessful in getting it to work (R v2.0.1).  Essentially, I'm
trying to highlight one or more of the surface wireframe lines in a
bolder (or different) color.  Any tips from those of you who have some
experience with this would be greatly appreciated.  [Would it be easier
using wireframe() in library(lattice) instead?]



Here's an example that just overlays two persp() plots ...

x <- seq(-10, 10, length= 30)
y <- x
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
z[is.na(z)] <- 1
op <- par(bg = "white")
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
      zlim=range(z))

# overlay plot with just "highlighted" surface area
par(new=TRUE)
z2 <- matrix(NA, ncol=30, nrow=30)
xi <- 15:18
yi <- 13:14
z2[xi, yi] <- z[xi, yi]
persp(x, y, z2, theta = 30, phi = 30, expand = 0.5,
      zlim=range(z), border="red", col="pink", box=FALSE, axes=FALSE)


And, any suggestions on how to add text outside of the persp() plot next
to the highlighted line would be much appreciated.



Do you mean like a legend?

Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
 tel  023-8059-7743


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to