我找不到为什么我的错误栏与我的栏相比如此之大?非常感谢!
df3
Amplitudes QF Detect_Bin sd
1 3 0.5 0.2118056 0.2909918
2 3 1 0.2037037 0.3012713
3 3 1.25 0.1701389 0.2931458
4 6 0.5 0.5729167 0.4023829
5 6 1 0.4994213 0.4057509
6 6 1.25 0.4085648 0.4043558
7 9 0.5 0.7384259 0.3479116
8 9 1 0.6574074 0.3831921
9 9 1.25 0.5821759 0.4015536
bar<-ggplot(df3, aes(x= Amplitudes, y= Detect_Bin, fill=Amplitudes))
bar+
geom_bar(stat="identity")+
geom_errorbar(aes(ymin=Detect_Bin-sd, ymax=Detect_Bin+sd), width = .2, size=0.5)+
facet_wrap(~QF)+
labs(x="Amplitude du SS", y="Moyenne de détection")
图情节
我已经复制了你的情节,代码没有任何问题。使用ymin=Detect_Bin-sd
和ymax=Detect_Bin+sd
生成错误栏。sd列的值大于或接近Detect_bin中的值。如表中所示,这些值是正确的。
df3 <- data.frame("Amplitudes" = c(3,3,3,6,6,6,9,9,9), "QF" = c(0.5,1,1.25,0.5,1,1.25,0.5,1,1.25), Detect_Bin = c(0.2118056, 0.2037037, 0.1701389, 0.5729167, 0.4994213, 0.4085648, 0.7384259, 0.6574074, 0.5821759), sd = c(0.2909918, 0.3012713, 0.2931458, 0.4023829, 0.4057509, 0.4043558, 0.3479116, 0.3831921, 0.4015536))
df3$Amplitudes <- factor(df3$Amplitudes, levels = c("3","6","9"))
df3 %>% mutate(ymin = Detect_Bin-sd, ymax= Detect_Bin+sd)
<表类>振幅 《 Detect_Bin sd ymin ymax tbody><<tr>3 0.50 0.2118056 0.2909918 -0.0791862 0.5027974 3 1.00 0.2037037 0.3012713 -0.0975676 0.5049750 3 1.25 0.1701389 0.2931458 -0.1230069 0.4632847 60.50 0.5729167 0.4023829 0.1705338 0.9752996 61.00 0.4994213 0.4057509 0.0936704 0.9051722 61.25 0.4085648 0.4043558 0.0042090 0.8129206 9 0.50 0.7384259 0.3479116 0.3905143 1.0863375 9 1.00 0.6574074 0.3831921 0.2742153 1.0405995 9 1.25 0.5821759 0.4015536 0.1806223 0.9837295 表类>