How to increase the space between the bars in a bar plot in ggplot2?
We can always play with the width parameter, as shown below:
df <- data.frame(x=factor(LETTERS[1:4]), y=sample(1:100, 4))
library(ggplot2)
ggplot(data=df, aes(x=x, y=y, width=.5)) +
geom_bar(stat="identity", position="identity") +
opts(title="width = .5") + labs(x="", y="") +
theme_bw()
The width in geom_bar controls the bar width in relation to the x-axis while the width in position_dodge controls the width of the space given to both bars also in relation to the x-axis. We can change the width and obtain various bar plots with different width