[R] persp( ) Question

Martin Maechler maechler at stat.math.ethz.ch
Sat May 14 16:25:11 CEST 2005

>>>>> "DavidB" == Brahm, David <David.Brahm at geodecapital.com>
>>>>>     on Fri, 6 May 2005 14:16:19 -0400 writes:

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

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

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

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

Yes, I had similar thoughts many weeks ago, and already then
prepared to add to trans3d().  Will do this now (for R 2.2.0).


More information about the R-help mailing list