0

I have a lattice xyplot with smoothed lines (6 different lines). I would like to change the line types- color and type of line (dashed, etc), so that they are understandable in B&W, rather than in color (which is the default). Can anyone provide advice on this? Below is my current code:

xyplot(y~x,
 data=df,
 group=categorical,
 type = "smooth",
 ylim=c(-2,0.5),
 xlab="x",
 ylab="y",
 auto.key=list(space="top",
 columns=3,
 title="",
 cex.title=0.1,
 lines=FALSE, points=TRUE)
)

Thank you

Mirza Obaid
  • 1,707
  • 3
  • 23
  • 35
Autumn
  • 11
  • 1
  • 1
    Hi, welcome to SO! Please try making your question [more reproducible](http://stackoverflow.com/a/5963610/4240010) – yeedle Apr 24 '17 at 00:55

1 Answers1

1

There are two options. Either you just set the line type with lty = 1:x or you use the built in black-and-white theme -- the latter will set up a bunch of other settings as well.

library(lattice)

y <- c(rnorm(10), rnorm(10, 2, 0.2), rnorm(10, 1.5, 0.4))
x <- rep(1:10, times = 3)
z <- rep(letters[1:3], each = 10)


# Option 1
xyplot(y ~ x, groups = z, type = "l",
       par.settings = standard.theme(color = FALSE))


# Option 2
xyplot(y ~ x, groups = z, type = "l", lty = 1:3, col = "black")

enter image description here

Johan Larsson
  • 3,496
  • 18
  • 34