Skip to content

xyplot color question

2 messages · Paul Heinrich Dietrich, Gabor Grothendieck

#
Hi,
I am plotting scatterplots of horsepower by torque, conditional on brand
(I'm just making up the variables for this example), and the goal is to see
both the scatterplot points as well as the smoothed line.  When I do the
following code, I get the same color for the points and line, and would like
the colors to be different, such as black points and a red smoothed line. 
How do I do that?  I can't find any examples or figure out how to manipulate
color.  Thanks.

xyplot(horsepower ~ torque | brand, MyData, type=c("p","smooth"))
#
Using data frame CO2, built into R, try this:

library(lattice)
p <- function(..., col) {
	panel.xyplot(..., type = "p", col = col[1])
	panel.xyplot(..., type = "smooth", col = col[2])
}
xyplot(conc ~ uptake | Treatment, CO2, panel = p, col = 1:2)


On Mon, Mar 2, 2009 at 9:13 AM, Paul Heinrich Dietrich
<paul.heinrich.dietrich at gmail.com> wrote: