the idea is simple:
(1)Use red dot for actual data;
(2)Use blue dashed line for fitted value.
But I just could not find a way to make such legend.
My fig and code below:

library(ggplot)
x <- seq(1,100,1)
y <- 2*x + runif(100,-5,5)
fit_y <- 2*x
df <- data.frame(x=x, y=y,fit_y=fit_y)
df
ggplot(df)+
geom_point(aes(x=x, y=y, color='point', shape='point'))+
geom_line(aes(x=x, y=fit_y, color='line', linetype='line')) +
scale_color_manual(values=c('point'='red', 'line'='blue')) +
scale_linetype_manual(values = c('line'='longdash')) +
scale_shape_manual(values = c('point'=1 ))
And I am pretty confused about that: Why is color legend composed of line and point?
Now it is a "blue line + blue point" PLUS "red line + red point".
But I only assign red to geom_point and blue to geom_line! Why is this?


ggplot(df) + geom_point(aes(x=x, y=y), color='blue') + geom_line(aes(x=x, y=fit_y), color='red', linetype='longdash')? - zx8754