ggplot2 : How to reduce the width AND the space between bars with geom_bar

Rather than taking the width smaller, which narrows the bars but increases the inter-bar space, set width = 1 to remove all space between.*

ggplot(iris, aes(Species, Petal.Length, fill=Species)) + geom_bar(stat="summary", width=1)

enter image description here

The default value is 0.9, so you can get very small spaces by setting width = 0.95

ggplot(iris, aes(Species, Petal.Length, fill=Species)) + geom_bar(stat="summary", width=0.95)

enter image description here

  • With fill=Species, I took the liberty of adding color to help see the different bars when there is no space between.

I would adjust the plot's aspect ratio, and have ggplot automatically assign the right width for the bars and the gap between them:

  ggplot(iris, aes(Species, Petal.Length)) + 
      geom_bar(stat="summary", width=0.4) +
      theme(aspect.ratio = 2/1)

Produces this:

enter image description here