I understand that one can change the width of a bar in geom_bar
using the width
argument. That does work, but then it creates a larger gap between the bars. Is there a way to manually push the bars closer to together? Should I be manipulating the axis somehow instead?
Here is an example, changing width to 0.3 on the right to get the desired bar width.
library(tidyverse)
library(gridExtra)
p1 <- ggplot(iris, aes(Species, Petal.Length)) + geom_bar(stat="summary")
p2 <- ggplot(iris, aes(Species, Petal.Length)) + geom_bar(stat="summary", width=0.3)
grid.arrange(p1,p2,nrow=1)
Note: I know this question is similar to this one, but the answer to closing the gap was not apparent.
p1 + coord_fixed(ratio = 0.02)
? – Raisedposition_dodge()
– Herat