I have the following minimal example:
df1 <- data.frame(x=1:10, y=rnorm(10))
df2 <- data.frame(x=11:20, y=rnorm(10))
df3 <- data.frame(x=1:10, y=rnorm(10,3,1))
df4 <- data.frame(x=11:20, y=rnorm(10,3,1))
ggplot() +
geom_line(data = df1, aes(x = x, y = y, color = "red")) +
geom_line(data = df2, aes(x = x, y = y, color = "red"), linetype="dashed") +
geom_line(data = df3, aes(x = x, y = y, color = "blue")) +
geom_line(data = df4, aes(x = x, y = y, color = "blue"), linetype="dashed") +
theme_bw() +
theme(legend.title=element_blank()) +
theme(legend.text=element_text(size=12)) +
theme(legend.position = c(.9,.89))
How can I have another legend at the top left of the graph for lines and dashed lines with labels c("Fitted values", Predicted Values")
?
I read This, This, and This, but still I can't solve it.
Thanks,