Thanks David,

I was hoping for something a little bit more generic and less case-by-case basis.

Sebastien

On 7/30/2015 3:51 PM, David Winsemius wrote:
On Jul 30, 2015, at 8:37 AM, sbihorel wrote:

Hi,

When the as.layer function is used to overaly 2 lattice plots, there seems to be an assumption that 
the data used in both plots will generate the same number of panels (and, I believe, in the same 
order). In case the data used in the plot within the as.layer call is incomplete , data may be 
plotted on the "wrong" panel, and data seem to get re-used on the last panel(s). See what 
happens in the example code below when the records with state.region=="South" are 
dropped...

Is there a trick to overlay panel based upon the conditioning variable value 
rather than the panel order?

require(lattice)
require(latticeExtra)
state2 <- state <- data.frame(state.x77,state.region)
state2$Income <- sample(state2$Income)
state3 <- state2[which(state2$state.region!="South"),]
foo <- xyplot(Income~Population|state.region,data=state,main='foo')
foo

bar <- update(foo,main='bar') + 
as.layer(xyplot(Income~Population|state.region,data=state2,col='red'))
bar

bar2 <- update(foo,main='bar2') + 
as.layer(xyplot(Income~Population|state.region,data=state3,col='red'))
bar2
I don't know if this works using the `+.lattice` function but it is possible to 
selectively update panels using `trellis.focus`


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to