[R] Contour lines in a persp plot

Matthew sobom.some at univ-fcomte.fr
Fri May 17 14:30:58 CEST 2013

Thanks a lot, that is all i want. If someone is interessed, see the code

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.

More information about the R-help mailing list