Hi All,

I am having some trouble getting lattice to display the legend names by row
instead of by column (default).

Example:

library(lattice)
set.seed(456846)
data <- matrix(c(1:10) + runif(50), ncol = 5, nrow = 10)
dataset <- data.frame(data = as.vector(data), group = rep(1:5, each = 10),
time = 1:10)

xyplot(data ~ time, group = group, dataset, t = "l",
  key = list(text = list(paste("group", unique(dataset$group)) ),
    lines = list(col = trellis.par.get()$superpose.symbol$col[1:5]),
    columns = 4
  )
)

What I'm hoping for are 4 columns in the legend, like this:
Legend row 1: "group 1", "group 2", "group 3", "group 4"
Legend row 2: "group 5"

However, I'm getting:
Legend row 1: "group 1", "group 3", "group 5"
Legend row 2: "group 2", "group 4"

I can see how this might work if I include blanks/NULLs in the legend as
placeholders, but that might get messy in data sets with many groups.

Any ideas on how to get around this?

Thanks,
Richard

	[[alternative HTML version deleted]]

