[R] 3d plotting from a 2d array
Duncan Murdoch
murdoch.duncan at gmail.com
Mon Nov 12 01:25:38 CET 2012
On 12-11-11 7:08 PM, Jake Roth wrote:
> Hi,
>
> I'm new to R and am learning the ropes of r-help and programming.
>
> I'm attempting to plot a 2-D mesh in 3-D using the persp function. I've
> positioned the graph using phi and theta, but I'm having trouble overlaying
> color onto the actual surface according to the surface's "z" values. I've
> tried the "col" feature but it doesn't put a flowing color gradient on the
> entire surface...
>
> Additionally, the xlab and ylab labels are appearing squished on the outer
> edges of the chart. Is there any way to get rid of the arrow along the
> axes and replace them with ticks and labels? "nticks" wasn't working...
>
> Is persp the best way to 3-D plot a 2-D array where I can overlay color??
>
> Any guidance would be greatly appreciated.
>
An alternative is the persp3d function in the rgl package. It handles
colour differently from persp: vertices get colours, rather than
facets. That might give you the gradient you want.
Duncan Murdoch
More information about the R-help
mailing list