Hi
jjorgensen at fastmail.fm 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
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/