I am trying to a graph combining scatter points from original dataset and predicted lines from the model. I want to group and color the scattered point by 3 income quantile and set corresponding color for the predicted lines (Low, medium and high income).
I tried to do that by setting "fill" for the points and "color" for the lines. But for some reason, once I add the scale_color_manual() command line, the points became all black.
colors <- c("Lowest Income Area" = "#00AFBB", "Median Income Area" = "#E7B800", "Highest Income Area" = "#FC4E07")
p <- ggplot() +
theme_minimal() +
geom_line(data = new_data,aes(x = x,y = predictions1, color = "Lowest Income Area"), size = 1.5) +
geom_line(data = new_data,aes(x = x,y = predictions2, color = "Median Income Area"), size = 1.5) +
geom_line(data = new_data,aes(x = x,y = predictions3, color = "Highest Income Area"), size = 1.5) +
geom_point(data = SBC_bg_df, aes(x = x,y = observed, fill=factor(income_3q)), size = 3) +
scale_fill_manual(values = colors) +
scale_colour_manual(breaks=c("Lowest Income Area", "Median Income Area", "Highest Income Area"),
values = colors) +
labs(x = "X", y = "Y", title = "Predicted X over Y", colour = "Predicted", fill="Observed")
p