[R]: (Lattice): Overlaying more than one trend surface using contourplot() and wireframe()

Deepayan Sarkar deepayan at stat.wisc.edu
Sat Aug 7 19:37:47 CEST 2004


On Saturday 07 August 2004 11:29, Peter Ho wrote:
> Deepayan,
>
> Thanks alot for your help. I managed to rescale the 3rd response
> variable, which was what Montgomery did in  the example. Plotting the
> 3rd surface was as easy as including a 3rd argument for "MW".
>
> The only problem now is to work out how to shade a particlar area of
> interest, depending on selected constrainst for each response. I ´ll
> try working on that next.

If I understand you correctly, this may not be trivial. The only way I 
can think of is to duplicate the surface (which is sort of cheating), 
and set complementary parts to NA. For example, consider

bar = expand.grid(x = seq(-1, 1, length = 50), 
                  y = seq(-1, 1, length = 50))
bar$z = with(bar, exp(-x^2) * exp(-abs(y)))
wireframe(z ~ x * y, bar)


Then, to highlight the region where z > 0.5, you could do 


foo = rbind(bar, bar)
foo$g = rep(1:2, each = nrow(bar))
foo$z[foo$g == 1 & foo$z < 0.4] <- NA
foo$z[foo$g == 2 & foo$z > 0.5] <- NA
wireframe(z ~ x * y, foo, groups = g)

In your case, the groups argument to wireframe will have to be the 
interaction of the earlier grouping variable and the new one.

Deepayan




More information about the R-help mailing list