One solution would be to place subset()your data inside geom_smooth()and indicate the value for which you need to build a trend line.
Data was used as an example mtcars(since no example data was provided). If the value is subset() cylselected, values 4 or 6. Insede should geom_smooth()also aes()be repeated.
ggplot(mtcars,aes(wt,mpg,color=factor(cyl)))+geom_point()+
geom_smooth(data=subset(mtcars,cyl==4 | cyl==6),
aes(wt,mpg,color=factor(cyl)),method=lm,se=FALSE)

source
share