Yu Deng
Yu Deng

Reputation: 1061

Change line thickness for specific line in ggplot in R

I would like to change the line thickness for State = "A" to 2, but scale_size_manual doesn't seem to work for stat_smooth type of line-plotting.

Could someone let me know how to change line thickness for this specific condition?

   aaa = data.frame(State=rep(c("A","B","C"),100),x= rnorm(300),y=rnorm(300))
   ggplot(aaa,aes(x=x, y=y,col=State))+ 
          geom_point() + 
          stat_smooth(method=glm,se=FALSE,aes(col=State)) +  
          scale_size_manual(values = c(2,1,1))

Upvotes: 1

Views: 3019

Answers (1)

Marat Talipov
Marat Talipov

Reputation: 13304

Add size=State in stat_smooth, i.e.:

ggplot(aaa,aes(x=x, y=y,col=State))+ 
       geom_point() + 
       stat_smooth(method=glm,se=FALSE,aes(col=State,size=State)) +  
       scale_size_manual(values = c(2,1,1))

enter image description here

Upvotes: 1

Related Questions