[R] Lattice: how to have multiple wireframe nice intersection?

David Winsemius dwinsemius at comcast.net
Fri Jan 16 21:44:46 CET 2009


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

> Hello,
>
> This code builds a simple example of 2 wireframes :
>
> require(lattice)
> x <- c(1:10)
> y <- c(1:10)
> g <- expand.grid(x = 1:10, y = 1:10, gr = 1:2)
> g$z <- c(as.vector(outer(x,y,"*")), rep(50,100))
> wireframe(z ~ x * y, data = g, groups = gr, scales = list(arrows =  
> FALSE))
>
> However, the intersection between the wireframes is not properly  
> drawn. Is there a way to fix this with lattice, or should I use   
> another package more suitable for this?

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
-- 
David Winsemius
>
>
> Thanks!
>
> Guillaume
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list