I am trying to make a plot using geom_smooth with different color patterns. However, I am getting two legends one with blue color (solid and dashed lines) and one with two different colors (solid lines). I want the dashed and solid lines to be different colors. How can I fix this error? Here is the code and output.
df<-data.frame(y=rnorm(200,30,20),x=rnorm(200,20,10),treat=factor(rbinom(100,1,0.5)))
p2 <- ggplot(df, aes(x=x, y=y, group=treat, color = treat))+
geom_point(size = 2)+
geom_smooth(aes(linetype=treat), se = F)+
labs(x ="tf", y = "xm") +
theme_bw() +
scale_linetype_manual(values=c( "solid", "dashed"),
labels = c("3", "4"))+
scale_color_manual(values = c("#00AFBB", "#E7B800"))
p2