I have mapped the Sex variable into the scatterplot, and GGPlot automatically gives me a legend for Sex, but I can't add the abline to the legend no matter what I try. I need to mark the black line as abline in the legend.
library(tidyverse)
ggplot(y_ela_test.total_sex, aes(x=Age, y=s0, color=Sex, shape=Sex)) + geom_point() + geom_smooth(method=lm,aes(color = Sex, fill = Sex))+theme(plot.title = element_text(hjust = 0.5, vjust=4, size = 10))+geom_abline(color="black",linetype="dashed",size=1)
enter image description here I output like this.
But I need to mark the black line as abline in the legend.
the dataset like this.