Reputation: 133
I have data in the melted form
b <- data.table(q = seq(5),
A = rnorm(5, mean=1, sd=1),
B = rnorm(5, mean=1.5, sd=1),
C = rnorm(5, mean=2, sd=1))
longb <- melt.data.table(b, id.vars = 'q', measure.vars = c(names(b)[-1]))
The to draw three lines one has to do:
ggplot(data = longb, aes(x = q, y = value, colour = variable)) +
geom_line()
I wander if it is possible to change one of the series (say C) from being line to being dotted graph (like geom_point()
)?
Upvotes: 0
Views: 203
Reputation: 3266
Something like this?
ggplot(data = longb, aes(x = q, y = value, colour = variable)) +
geom_line(aes(linetype = (variable == "C"))) +
guides(linetype = "none")
Or better:
ggplot(data = longb, aes(x = q, y = value, colour = variable)) +
geom_line(aes(linetype = variable)) +
scale_linetype_manual(values = c(1,1,3))
Or well?:
ggplot(data = longb[variable != "C"], aes(x = q, y = value, colour = variable)) +
geom_line() +
geom_point(data = longb[variable == "C"], aes(x = q, y = value))
Upvotes: 2