我试图为我的两组平均值获得一条趋势线,在我的主图中,我将在点上放置误差线以显示 sd,但下面是一个简化版本:
ggplot(sl, aes(x=Stresslevel, y=Final, color=Treatment)) +
geom_point() +
geom_smooth(method = "lm")
在我的输出中,我可以在图例中看到它正在尝试添加它,但它没有显示在图表上: 在此处输入图像描述
这是数据的图像: 在此处输入图像描述
编辑:这是我的数据,谢谢你的建议>
dput(sl)
structure(list(Stresslevel = structure(c(1L, 2L, 3L, 4L, 5L,
6L, 7L, 3L, 4L, 5L), .Label = c("0", "1", "2 (30%)", "3 (50%)",
"4 (70%)", "5", "Recovered"), class = "factor"), WL = c(0, 15.5,
32.8, 52.9, 69.8, 89.2, 13.5, 30, 50, 70), WLsd = c(5, 6.5, 8.1,
8.8, 10.6, 4.2, 9.8, 5, 5, 5), Final = c(0.0292, 0.0276, 0.0263,
0.0248, 0.0208, 0.0199, 0.0249, 0.0274, 0.0235, 0.0121), Treatment = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("Stressed", "Treated"
), class = "factor"), Finalsd = c(0.0039, 0.0019, 0.0026, 0.0033,
0.002, 0.0021, 0.0028, 0.0049, 0.0048, 0.0026), Dry = c(0.006,
0.008, 0.0107, 0.0139, 0.0138, 0.0174, 0.0047, 0.008, 0.0116,
0.0105), Drysd = c(0.0015, 0.0015, 0.0017, 0.0024, 0.0011, 0.0022,
0.001, 0.0016, 0.0033, 0.0021), Delta = c(0.0231, 0.0196, 0.0155,
0.0109, 0.007, 0.0025, 0.0201, 0.0194, 0.012, 0.0016), Deltasd = c(0.0034,
0.0015, 0.0019, 0.002, 0.0024, 0.001, 0.0025, 0.0043, 0.0035,
0.0013), WC = c(4.07, 2.54, 1.48, 0.81, 0.52, 0.15, 4.44, 2.48,
1.11, 0.16), WCsd = c(1.22, 0.59, 0.26, 0.21, 0.2, 0.08, 1.06,
0.56, 0.45, 0.12), CD = c(1, 1.33, 1.78, 2.31, 2.29, 2.89, 0.78,
1.33, 1.92, 1.75), CDsd = c(0.24, 0.25, 0.28, 0.4, 0.19, 0.37,
0.16, 0.26, 0.54, 0.35)), class = "data.frame", row.names = c(NA,
-10L))
任何帮助将不胜感激。