[R] Surface plotting

Duncan Murdoch murdoch at stats.uwo.ca
Thu Nov 13 16:27:42 CET 2008

On 11/13/2008 8:51 AM, mentor_ wrote:
> Hi,
> I would like to plot a matrix which comprises 3 columns.
> So first column should be the x-axis.
> Second the y-axis and the third one should be the z-axis.
> I know that I can plot such data using the scatterplot3d, but I would like
> to
> have a surface plot like you can do with wireframe and persp. But both,
> persp and wireframe,
> want to have x and y as descending data, at least persp. I am not sure but
> wireframe is actually
> doing excatly the same.
> So is there a way to plot each of the three columns on a different axis and
> having a surface?

You can do this in rgl, but not with data exactly as you describe.  In 
the persp3d and surface3d functions, the x, y and z coordinates can be 
specified as in persp (z as a matrix, x and y as vectors labelling the 
rows and columns), but x and/or y can also be matrices.  This is useful 
when the surface you're plotting isn't in the form z = f(x,y).

You can't really do it with vectors for all three without some 
convention saying which points form a quad on the surface.

Duncan Murdoch

More information about the R-help mailing list