有谁知道为什么错误栏被放在彼此之上而不是基于variable
分组?不要介意我的数据中的dulpcated列。
> head(dual_average_sd)
siRNA Time variable average siRNA variable sd
1 Fluc-3-x-Bp3Mid 2 Avg100nM 1.1360882 Fluc-3-x-Bp3Mid Std100nM 0.380483728
2 Fluc-3-x-Bp3Mid 4 Avg100nM 1.0289251 Fluc-3-x-Bp3Mid Std100nM 0.206174705
3 Fluc-3-x-Bp3Mid 6 Avg100nM 0.8314746 Fluc-3-x-Bp3Mid Std100nM 0.053001934
4 Fluc-3-x-Bp3Mid 12 Avg100nM 0.7197690 Fluc-3-x-Bp3Mid Std100nM 0.008183043
5 Fluc-3-x-Bp3Mid 24 Avg100nM 0.4688671 Fluc-3-x-Bp3Mid Std100nM 0.015459736
6 Fluc-3-x-Bp3Mid 48 Avg100nM 0.4912145 Fluc-3-x-Bp3Mid Std100nM 0.038062323
p <- ggplot(dual_average_sd, aes(x=siRNA, y=average, fill=variable)) + geom_bar(stat="identity",position = "dodge") +
theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + facet_grid(~Time)
p + geom_errorbar(aes(ymin=average-sd, ymax=average+sd
),width=.3, position=position_dodge(0.05)) +
labs(x="Time (h)", y="FLuc/RLuc") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + facet_grid(~Time)
答案 0 :(得分:3)
您需要增加position_dodge()
的值,例如:
geom_errorbar(aes(ymin=average-sd, ymax=average+sd),
width=.3,
position=position_dodge(1))