Message-ID: <3cf9f70cc9df289f6cfdb868581fd38d.squirrel@webmail.eden.rutgers.edu>
Date: 2009-05-27T17:41:54Z
From: Jack Siegrist
Subject: contour lines on persp plot
Hello folks,
I am a beginner R user. I have been able to make a 3D surface plot using
'persp'. The surface is made by a grid of lines emanating perpendicularly
from each of the x and y axes at regular intervals.
I can get rid of that grid by setting 'border=NA'.
Can anyone suggest some ways to replace the grid with contour lines, to
create a 3-dimensional contour map?
Thanks for any help.
Here is an example of what I have so far:
#to create a perspective plot; plots funct. across all combos of x and y
fn<-function(x,y){sin(x)+2*y} #this looks like a corrugated tin roof
x<-seq(from=1,to=100,by=1) #generates a list of x values to sample
y<-seq(from=1,to=100,by=1) #generates a list of y values to sample
z<-outer(x,y,FUN=fn) #applies the funct. across the combos of x and y
persp(z,col='lightgray',shade=.5,border=NA,) #plots without gridlines