Skip to content
Prev 106682 / 398525 Next

lattice xyplot: plot multiple lines with different colors

Bram Kuijper wrote:
I don't know about dynamically determining the number of lines, but
the following gives different colors for each line automatically:

library(lattice)
df <- data.frame(a = runif(10), b = runif(10), c = runif(10), x = 1:10)
xyplot(a + b + c ~ x, data = df, type = "l", auto.key=TRUE)