[R] Contour lines in a persp plot

smsome at univ-fcomte.fr smsome at univ-fcomte.fr
Thu May 16 17:23:07 CEST 2013


Hello folks,

i'm a R beginner and i want to put in a same plot both contour lines  
and persp plot.

For example,

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) #plots without gridlines
contour(z) # for contour lines

i want this in a same plot.
Can anyone help me, i have no more idea to try this.

Thanks



More information about the R-help mailing list