0

I'm making a grouped bar chart with ggplot2. I have this code...

ggplot(data = dummy,
       aes(
         fill = Geography2,
         x = Group,
         y = PunishmentRate
       )
) +
  geom_bar(
    position = "dodge",
    stat = "identity",
    width = 0.5,
    binwidth = 0
  ) +
  coord_flip() +
  geom_text(data = subset(dummy, Group == "White"),
            aes(
              label = Geography2,
              y = 0
            ),
            position = position_dodge(0.5),
            hjust = 0
  )

That makes this chart...

enter image description here

I thought adding binwidth parameter in geom_bar() would bring the groups closer together, but it did not. How do I bring the groups closer together?

Username
  • 3,463
  • 11
  • 68
  • 111
  • Check out the answer here: https://stackoverflow.com/questions/15400486/change-distance-between-x-axis-ticks-in-ggplot2 – iod Sep 18 '18 at 15:50
  • @aosmith I want to keep the bars narrow – Username Sep 18 '18 at 15:58
  • 1
    Try making the "wide" bars but then adjust the final height of the plot you save. This way you can still make the bars narrow. – aosmith Sep 18 '18 at 16:09

0 Answers0