[R] Help on plotting a 3 dimensional surface

Duncan Murdoch
Sat, 03 Jun 2006 11:09:23 -0000

On 6/3/2006 5:54 AM, Tor J?rund Sund wrote:
> Hi
>
>
>
> Im working on my master thesis, I need to get a plot currents distributed
> over a surface.
>
> I have the data listed in a dataframe with the x coordinates, y coordinates
> and the value.
>
> Im using the persp function but I?ve not found out how to put the data into
> the z1 variable
>
>
>
> es
<-read.table("RDatalog_pass_dev_1_wafers_1_8V.txt",header=T,sep="\t")
>
> x1 <- seq(0,40, length=40)
>
> y1 <- x1
>
> z1 <- ? (es[,5]is the column with the data, es[,3] is the x coocdinate,
and
> es[,2] is the y coocrdinate]
>
> persp(x1,y1,z1)
>
>
>
> I will appreciate all help because this will be a nice thing to present in
> my report.

In order to plot a surface, the z values need to be arranged in a
matrix, with the x and y values labelling rows and columns.  If you have
a single z value for each (x,y) pair, you can do a 3d scatterplot using
the scatterplot3d package, or the cloud function in the lattice package.
  You can also convert them to a surface using interp from the akima
package, and then they'll work with persp.

Duncan Murdoch