0
我有以下的小例子:两种传说基于不同的数据集与GGPLOT2两个不同的位置
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))
我怎么能有另一个传奇在图形的线左上角和虚线与标签线c("Fitted values", Predicted Values")
?
感谢,
非常感谢。它适用于我,它比其他人在[链接]中提到的解决方案容易得多(https://stackoverflow.com/questions/13143894/how-do-i-position-two-legends-independently-in- ggplot)。继续做好:) – Alirsd