Skip to content
Prev 178740 / 398506 Next

Grouping multiple runs of multiple datasets in lattice's xyplot

On Mon, Apr 27, 2009 at 12:33 PM, Daniel Kornhauser
<dkor at northwestern.edu> wrote:
myColors <- c("red", "blue")

xyplot(y ~ x | factor(conditional.var),
       data = dat,
       groups = interaction(dataset, run),
       col = myColors,
       ylab =  NULL,
       type = "l",
       key = list(text = list(c("1", "2")),
                  lines = list(col = myColors),
                  space = "right"))

The trick is to specify just two colors, and create the interaction()
in the right order so that the colors get recycled properly.

-Deepayan