Adjust linetype of One Line in a facet_grid
facet, ggplot2, r
Solution
One of the first, and most important, things you're going to learn about ggplot2 is that when you want something to appear on your plot, you will in general create a variable in your data frame that represents the visual information you wish to display.
In your case, you need a variable that picks out only those observations from panel a, line 1:
b$grp <- with(b,(f == "a") & (c == 1))
Then you can map both `size` and `linetype` to this variable, and adjust the scales manually:
library(scales)
ggplot(b,aes(x=x,y=y)) +
geom_line(aes(color=c,group=c,size = grp,linetype = grp)) +
facet_grid(f ~ .) +
scale_size_manual(values = c(0.5,1.2),guide = "none") +
scale_linetype_manual(values = c('solid','dashed'),guide = "none")
Problem
I have a plot similar to this one: ``` b <- data.frame(x=c(1,2,3,1,2,3,1,2,3,1,2,3),y=c(1,2,3,1.5,1.9,2.5,3,2,1,2.9,1.8,1.5),c=c("1","1","1","2","2","2","1","1","1","2","2","2"),f=c("b","b","b","b","b","b","a","a","a","a","a","a")) ggplot(b,aes(x=x,y=y,color=c,group=c))+geom_line()+facet_grid(f ~ .) ``` Now I want only the line "1" in the upper facet "a" to be thicker and dashed. Is this possible?