Yu, Xuesong
2009-Feb-11 20:07 UTC
[R] 2 different colors for 2 groups of lines using xyplot
Hi All, I am trying to use xyplot to plot several lines in one panel with red color for a group of lines, say 3 lines and blue color for another group of lines, say 4. I know this can be easily done using regular plot function. But i could not figure out how to do this in xyplot. Any help would be greatly appreciated. Xuesong [[alternative HTML version deleted]]
Dieter Menne
2009-Feb-12 07:36 UTC
[R] 2 different colors for 2 groups of lines using xyplot
Yu, Xuesong <xyu <at> scharp.org> writes:> I am trying to use xyplot to plot several lines in one panel with red > color for a group of lines, say 3 lines and blue color for another > group of lines, say 4. I know this can be easily done using regular > plot function. But i could not figure out how to do this in xyplot. >states <- data.frame(state.x77, state.name = dimnames(state.x77)[[1]], state.region = state.region) xyplot(Murder ~ Population, data = states, groups = state.region, col.line=c("red","red","green","green"), panel = panel.superpose, panel.groups = panel.loess) # Note the difference when colors are recycled xyplot(Murder ~ Population, data = states, groups = state.region, col.line=c("red","green"), panel = panel.superpose, panel.groups = panel.loess) Dieter