我發現很多問題都會在ggplot2
中處理重新定位錯誤條,但沒有一個具有我特殊問題。我希望這不是重複的!在一個多面條形圖上重新定位geom_errorbar
我有一個多面的barplot,我試圖在已經計算出的置信區間添加錯誤欄。參數stat
和position
似乎沒有任何影響,不管它們是在aes()
參數中還是僅在geom_errorbar()
。以下是我與合作:
> dput(anthro.bp)
structure(list(Source = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("PED", "RES"), class = "factor"),
Response = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("A", "B", "C", "D"
), class = "factor"), Value = c(0.5043315, 0.03813694, 0.20757498,
0.249956615, 0.9232598, 0.0142572, 0.0537258, 0.008757155,
0.897265, 0.03153401, 0.06610772, 0.005093254, 0.8360081,
0.03893782, 0.0370325, 0.088021559), Distance = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
), .Label = c("Near", "Far"), class = "factor"), UCI = c(0.5853133,
0.07247573, 0.27357566, 0.32335335, 0.9744858, 0.03844421,
0.08841988, 0.04262752, 0.9422062, 0.0540748, 0.09600908,
0.03348959, 1.2445932, 0.11196198, 0.10133358, 0.52272511
), LCI = c(0.4233497, 0.003798153, 0.1415743, 0.17655988,
0.8720338, -0.009929805, 0.01903172, -0.02511321, 0.8523238,
0.008993231, 0.03620636, -0.02330308, 0.427423, -0.034086335,
-0.02726858, -0.34668199)), .Names = c("Source", "Response",
"Value", "Distance", "UCI", "LCI"), row.names = c(NA, -16L), class = "data.frame")
anthro.bp[,4]<-factor(anthro.bp[,4], levels=c("Near","Far"))
bp <- ggplot(anthro.bp, aes(Value, fill=Response))
bp + geom_bar(aes(x=Source,y=Value), stat="identity", position="dodge") +
geom_errorbar(aes(ymin=LCI,ymax=UCI), stat="identity", position="dodge",width=0.25) +
facet_wrap(~Distance) +
labs(x="Disturbance Source", y="Mean Probability")
我也試圖在geom_errorbar()
命令都距離aes()
參數外的,要再次使用position=position_dodge(width=1)
。我的圖表如下鏈接(我沒有足夠的聲望來嵌入圖像,但道歉!)。
我也越來越兩個錯誤消息:
警告消息:
1:在loop_apply(N,do.ply):
position_dodge需要非重疊x上間隔
2:在loop_apply(n,do.ply)中:
position_dodge要求非重疊的x間隔
這是我第一次在教室環境之外使用ggplot2,因此非常鼓勵建設性的批評。
正確的主意,但計算錯誤欄的每條腿似乎增加了一個額外的步驟。 – Maalthou