Reputation: 34937
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?
Upvotes: 12
Views: 3474
Reputation: 191
The following works for me:
library(lattice)
mydata <- data.frame(y1=rnorm(10), y2=rnorm(10), x=1:10)
xyplot(y1 + y2 ~ x, mydata, auto.key=TRUE,
par.settings=simpleTheme(pch=1:4))
Upvotes: 0
Reputation: 37784
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:
Upvotes: 15