Question Details

No question body available.

Tags

r ggplot2 sjplot

Answers (1)

May 18, 2026 Score: 3 Rep: 70,870 Quality: Medium Completeness: 80%

You control the "space between" indirectly, by a combination of how wide the plot itself is (controlled by your graphics device), and how tight the bars in each group are dodged and/or how much spacing is added to the sides.

Suppose we have this plot, similar to yours. It's best practice to include sample data in your question, but I think your issue can be demonstrated as well with other data.

p  transform(am = factor(am))),
                        type = "pred", terms = c("am", "vs")) 

ggsave("p.png", p, width = 4, height = 3, scale = 2)

enter image description here

If we make the plot narrower (most immediately by resizing the Plot window, but more reproducible using ggsave()), and increase the dodge proportion, we can get a similar physical spacing between the bars in each group, but with less space in between.

p2  transform(am = factor(am))),
                        type = "pred", terms = c("am", "vs"), dodge = 0.5) 

ggsave("p2.png", p2, width = 2, height = 3, scale = 2)

(Annoyingly, stack overflow displays this plot larger to fill the width; the original file has the same height.)

enter image description here

If we want the same plot dimensions, we could add padding to the sides:

p3  transform(am = factor(am))),
                         type = "pred", terms = c("am", "vs"), dodge = 0.5) +
  scalexcontinuous(expand = expansion(mult = c(1, 1)))

ggsave("p3.png", p3, width = 4, height = 3, scale = 2)

enter image description here