width and gap of geom_bar (ggplot2)

Same problem but with side-by-side bars will be resolved using the width within the position element:

geom_bar(width=0.1, position = position_dodge(width=0.2))

Setting the width to a small value and specifying the color gives me the desired result with gaps between all bars:

ggplot(df, aes(x = Day, y = Mean)) +
  geom_bar(stat = "identity", width = 0.1, color = "black") +
  theme_bw() +
  theme(axis.text = element_text(size = 12))

the resulting plot:

enter image description here


If you want no gaps, use width = 1:

ggplot(df, aes(x = Day, y = Mean)) +
  geom_bar(stat = "identity", width = 1) +
  theme_bw(base_size = 12) 

the resulting plot:

enter image description here

Tags:

R

Ggplot2