[R] persp( ) Question

Brahm, David David.Brahm at geodecapital.com
Fri May 6 20:16:19 CEST 2005


Greg,

Assign the output of "persp" to a variable "pmat":
R> pmat <- persp(X.grid, Y.grid, pred.loess1, theta=0, phi=12)

Now you can add points to your plot with the usual "points" command.
But you have to translate your 3D coordinates (x,y,z) into 2D
coordinates for "points" to understand, and that's what "trans3d" does:

R> points(trans3d(x,y,z, pmat), col="red")

You supply the (x,y,z) values, of course.  It's a mystery to me why
"trans3d" is not included in the graphics package (where "persp" lives).
HTH.

-- David Brahm (brahm at alum.mit.edu)




More information about the R-help mailing list