[R] What does persp() return?

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Aug 2 09:08:46 CEST 2002

David Brahm wrote:
> Thanks very much to Paul Murrell, Ben Bolker, and Peter Dalgaard for
> responding.  Sorry I failed to find the 3/15/02 discussion of this same topic.
> May I suggest that the omission of the returned value from the help page for
> persp() is a "documentation bug"?  Something like this could be added:
> Value:
>   A 4x4 matrix (call it "pmat"), suitable for transforming 3D coordinates
> (x,y,z) into list(x,y) values.  These can then be used by lines(), points(),
> etc, to superimpose additional data on the 3D plot.  The transformation can be
> accomplished with the following function:
>   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,])
>   }

I must have missed the beginning of this thread.
After the mentioned similar discussion from march, I hacked (I mean:
*hacked*) a function
s3d.persp() that combines persp() with some of the ideas from
scatterplot3d(). s3d.persp() was included in one unpublished (in a way)
version of the package scatterplot3d, which is available at:


for the windows version.

Well, because of the hughe differences in the design of those functions
won't fit together easily. Since no clean solution can be found quickly,
I throw s3d.persp() away one day later, but it might be useful for you

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

More information about the R-help mailing list