Skip to content
Prev 167278 / 398502 Next

Lattice: how to have multiple wireframe nice intersection?

On Jan 16, 2009, at 9:43 AM, Guillaume Chapron wrote:

            
Exactly what "not properly drawn" means is not stated. If it is the  
jagged intersection, then expanding the grid would seem to be one way  
forward. Here's 100 x 100:

 > require(lattice)
 > x <-seq(1,10, len=100); y <- seq(1,10, len=100)
 > g <- expand.grid(x = seq(1,10, len=100), y = seq(1,10, len=100), gr  
= 1:2)
 > g$z <- c(as.vector(outer(x,y,"*")), rep(50,10000))
 > wireframe(z ~ x * y, data = g, groups = gr, scales = list(arrows =  
FALSE))

You do get some Moir`e effects, but the jagged intersection is no  
longer visible and the curvature is visible.

With 50*50 points it has a less obvious curvature to the intersection  
(but four times as fast).

require(lattice)
x <-seq(1,10, len=50); y <- seq(1,10, len=50)
g <- expand.grid(x = x, y = y, gr = 1:2)
g$z <- c(as.vector(outer(x,y,"*")), rep(50,length(x)*length(y)))
wireframe(z ~ x * y, data = g, groups = gr, scales = list(arrows =  
FALSE))

Or you could emphasize the curvature by drawing it in. I'm not the guy  
to do that, but there is an example of adding contours to a wireframe  
plot in Sarkar's book. Figure 13.7:

http://lmdvr.r-forge.r-project.org/figures/figures.html