我有bar plot:
p <- ggplot(data=df, aes(x=Gene, y=FC, fill=expt, group=expt))
p <- p + geom_bar(colour="black", stat="identity", position = position_dodge(width = 0.9))
p <- p + geom_errorbar(aes(ymax = FC + se, ymin = FC, group=expt),
position = position_dodge(width = 0.9), width = 0.25)
p
我想增加条形之间的间距(对于每个bin)。我已经尝试过使用position_dodge(width = ...)
,但它会使我的错误栏出现偏差:
还有其他几个与此相关的问题:
即似乎增加了箱子之间的间隔,但代价是与相邻的栏重叠
答案 0 :(得分:10)
您也可以调整geom_bar
以外的宽度(ggplot(data=df, aes(x=Gene, y=FC, fill=expt, group=expt)) +
geom_bar(colour="black", stat="identity", position = position_dodge(width = 0.8), width=0.5) +
geom_errorbar(aes(ymax = FC + se, ymin = FC, group=expt),
position = position_dodge(width = 0.8), width = 0.25)
),
dodge <- position_dodge(width = 0.5)
ggplot(data=df, aes(x=Gene, y=FC, fill=expt, group=expt)) +
geom_bar(colour="black", stat="identity", position=dodge, width=0.5) +
geom_errorbar(aes(ymax = FC + se, ymin = FC, group=expt),
position = dodge, width = 0.25)
或
gap:["PluginManager","startup","PluginManager307573941"]