Skip to content
Prev 9702 / 398498 Next

Graphical parameters in perspective plot

Hi
Unfortunately, all of the annotation functions -- text(), points(), lines(),
... -- only work in 2D.
In S-Plus, persp() returns a value that can be used to transform 3D
locations to 2D, but this sort of thing is not (yet) available in R.  If the
annotations you have in mind are _very_ simple then it might be enough to
make use of the value of par("usr").  For example, to stick a big ugly label
right in the middle of the persp plot you could do something like ...

    # one of the persp() examples
     x <- seq(-10, 10, length=50)
     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
     par(bg = "white")
     persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
           xlab = "X", ylab = "Y", zlab = "Z")

    # a very basic annotation
    text(mean(par("usr")[1:2]), mean(par("usr")[3:4]), "My Perspective Plot
!!", col="red", cex=3)

Again depending on what you want to do, Uwe Ligges' scatterplot3d package
might be useful because it appears to provide 3D to 2D transformations, .
persp() allows normal par() arguments to be passed to it, but unfortunately
it ignores virtually all of them.  This will hopefully be fixed in the
future.

Paul


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