Increase space between bars in ggplot

前端 未结 1 476
余生分开走
余生分开走 2020-12-03 09:27

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 = pos         


        
相关标签:
1条回答
  • 2020-12-03 09:44

    You can adjust the width outside of the position_dodge as well (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

    0 讨论(0)
提交回复
热议问题