我正在尝试为数据中的变量geom_crossbar
和etg
在eac
图表中添加折线图或点或其他内容。
我当前的代码如下:
library(ggplot2)
df <- data.frame(
SNL = c("af1","af2","af3","af4","af5","af6"),
etg = c(1408,1399,1382,1170,1026,869),
eac = c(1417,1447,1428,1415,1294,1422),
prediction = c(1463,1463,1471,1387,1447,1431),
lower = c(1296,1296,1304,1220,1280,1264),
upper = c(1631,1631,1638,1554,1614,1598)
)
ggplot(df, aes(x = SNL, y = prediction, ymin = lower, ymax = upper)) +
geom_crossbar(aes(color = SNL)) +
geom_point(aes(y = etg), shape = 1) +
geom_line(aes(y = eac, group = 1))
哪个创建:
如何为etg
和eac
显示适当的图例?