当我在网上找到代码时,我正在尝试使用ggplot函数geom_errobar()
添加简单的错误栏。
该函数有效,但是我不知道为什么它不能将点和条之间的线划掉。
在重新解释我在网上找到的代码的所有示例中,点和条之间总是有一条线,并且我使用相同的代码!!
短数据集
structure(list(Daytime = structure(c(17683, 17684, 17685, 17686,
17687, 17688, 17689, 17690, 17691, 17692, 17693, 17694, 17695,
17696, 17697, 17698, 17699, 17700, 17701, 17702, 17703, 17704,
17705, 17706, 17707, 17708, 17709, 17710, 17711, 17712), class = "Date"),
mz33_flux = c(0.0269902340425532, -0.0186273777777778, -0.0372041666666667,
-0.065895625, -0.0371895833333333, -0.0685152173913043, 0.0733608695652174,
-0.0462857446808511, 0.03306875, -0.0309327083333333, 0.0240914893617021,
0.0355631578947368, NA, NA, NA, NA, NA, NA, 1.32546206896552,
0.039425, -0.00267916666666666, -0.0299131111111111, -0.207063829787234,
0.0057391304347826, -0.0350862790697674, -0.0324617021276596,
-0.0234354838709677, -0.0835595744680851, 0.0966265957446808,
-0.0124054545454545), mz33_err = c(3.90466069268418e-05,
3.94858430704017e-05, 4.24302022766031e-05, 4.46591337717942e-05,
6.21204244886397e-05, 4.10959733730185e-05, 5.64638070309499e-05,
6.44166726780267e-05, 3.82000202086123e-05, 4.15227904947797e-05,
3.8179357878616e-05, 3.09029031996929e-05, NA, NA, NA, NA,
NA, NA, 0.00102801852277132, 3.86575696937507e-05, 2.93166992687375e-05,
3.24126251499621e-05, 5.68095205509716e-05, 7.24229986669278e-05,
5.91711611807517e-05, 7.34947840597977e-05, 6.30692813002305e-05,
5.4382594393826e-05, 9.84397824539971e-05, 3.30427039605518e-05
)), row.names = c(NA, 30L), class = "data.frame")
ggplot脚本
ggplot(df,aes(x=Daytime))+
geom_line(aes(y=mz33_flux,colour="y"), size = 1)+
geom_errorbar(aes(ymin=mz33_flux-mz33_err, ymax=mz33_flux+mz33_err), width=1,position=position_dodge(0.05),color="green")
我希望在点和误差线之间有连接线,如在函数示例图中所示。
答案 0 :(得分:1)