Вы можете ввести пустой фактор и настроить его так, чтобы он выглядел как график лесса.
library(ggplot2)
library(tidyverse)
mtcars2 <- mtcars %>%
mutate(vs2 = factor(vs, levels = c("0", "1", "dotted")
, labels = c("0", "1", "dotted")))
ggplot(mtcars2, aes(wt, mpg, color=vs2, linetype=vs2)) +
stat_smooth(method="loess", se=FALSE, color="green",
lty=2, show.legend=TRUE,
aes(group=vs2)) +
stat_smooth(method="lm", formula=y ~ poly(x, 2, raw=TRUE),
se=FALSE, show.legend=TRUE)+
theme_minimal() +
scale_color_manual(values = c("red", "blue", "green"), drop = FALSE) +
scale_linetype_manual(values = c(1, 1, 2), drop = FALSE)