[R] Plotting a 3D surface

Duncan Murdoch murdoch at stats.uwo.ca
Wed Oct 20 14:41:17 CEST 2004


On Wed, 20 Oct 2004 08:18:10 -0400, "lawrence Perepolkin"
<lperepol at necessity.org> wrote :

>Hi 
>
>Does R have a function or has someone written a function to draw a 3d
>surface from a scatter plot of values using either ksmooth or locpoly. OR a
>transform function a that merges x relation z and y relation z to (x,y)
>relation z?  
>
>I tried out scatterplot3d but it seems it would take a bit of work to get
>scatterplot3d to draw a curved surface.

persp() or functions in the rgl package can draw the curved surface,
but you'll need to calculate it yourself first.  You should fit a
model to the surface then use predict to find the predictions at every
grid point; that's the sort of data that persp() wants.  As far as I
know both ksmooth and locpoly are one dimensional scatterplot
smoothers, but other functions (e.g. gam() in mgcv) can do higher
dimensional smoothing.

Duncan murdoch




More information about the R-help mailing list