Increase the distance between the strips in ggplot

I have a 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 

I want to increase the distance between the bars (for each basket). I tried messing around with position_dodge(width =...) but this distorts my errors:

enter image description here

There are several other questions that relate to this:

  • There is an answer to this question that seems to be doing its job (but it is difficult to implement)
  • When I use the answer to this question, I get the following:

enter image description here

that is, it seems that between the bins it increases, but due to overlapping with the neighboring bar

+4
source share
1 answer

You can also adjust the width outside the position_dodge (in 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) 

enter image description here

or

 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) 

enter image description here

+8
source

All Articles