[R] contour lines on persp plot
Jack Siegrist
jacksie at eden.rutgers.edu
Wed May 27 19:41:54 CEST 2009
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
More information about the R-help
mailing list