Re: [R] Contour lines in a persp plot

2013-05-17 Thread Matthew
Thanks a lot, that is all i want. If someone is interessed, see the code
below

panel.3d.contour - 
function(x, y, z, rot.mat, distance, 
 nlevels = 20, zlim.scaled, ...) # les3 points de suspension
pour dire les autres paramètres sont ceux données par défaut
{
add.line - trellis.par.get(add.line)
panel.3dwire(x, y, z, rot.mat, distance, 
 zlim.scaled = zlim.scaled, ...)
clines - 
contourLines(x, y, matrix(z, nrow = length(x), byrow = TRUE),
 nlevels = nlevels)
for (ll in clines) {
m - ltransform3dto3d(rbind(ll$x, ll$y, zlim.scaled[2]), 
  rot.mat, distance)
panel.lines(m[1,], m[2,], col = add.line$col,
lty = add.line$lty, lwd = add.line$lwd)
}
}


fn-function(x,y){sin(x)+2*y} #this looks like a corrugated tin roof

x-seq(from=1,to=100,by=2) #generates a list of x values to sample
y-seq(from=1,to=100,by=2) #generates a list of y values to sample

z-outer(x,y,FUN=fn) #applies the funct. across the combos of x and y


wireframe(z,zlim = c(1, 300), nlevels = 10,
  aspect = c(1, 0.5), panel.aspect = 0.6,
  panel.3d.wireframe = panel.3d.contour,
   shade = FALSE ,
  screen = list(z = 20, x = -60))



--
View this message in context: 
http://r.789695.n4.nabble.com/Contour-lines-in-a-persp-plot-tp4667220p4667309.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Contour lines in a persp plot

2013-05-16 Thread smsome

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Contour lines in a persp plot

2013-05-16 Thread David Winsemius

On May 16, 2013, at 8:23 AM, sms...@univ-fcomte.fr wrote:

 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.

Ideas: I can tell you that I have seen an example that projects contour lines 
on one of the pseudo-3d coordinate planes of a wireframe (lattice) plot in 
Sarkar's Lattice book. (All of those examples are on the web and a google 
search: lattice wireframe contour plot  … is immediately productive of a 
citation to Figure 13.7 as well as links to the Rhelp archive.) To do something 
similar I imagine you would need to do work with the coordinate transform 
function, ?trans3d,  described on the ?persp page and use as input the results 
from ?contourLines.

-- 
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.