Question

What is the simplest way to make just this plot grayscale (or perhaps black and white) rather than the default multi-colour:

xyplot(y1 + y2 ~ x, mydata, auto.key=TRUE)

I've seen discussion of creating new graphics devices or changing options for all plots, but is there an option that I can include perhaps in the xyplot() function itself that will convert the plot to grayscale?

Was it helpful?

Solution

library(lattice)
bwtheme <- standard.theme("pdf", color=FALSE)
mydata <- data.frame(y1=rnorm(10), y2=rnorm(10), x=1:10)
xyplot(y1 + y2 ~ x, mydata, auto.key=TRUE, par.settings=bwtheme)

For comparison:

comparison of color vs black/white

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top