2

I'm adding a geom_text() object underneath my plot to give more information about my columns. It has multiple line breaks because, in my actual dataset, I have many columns, so unless I go down lower, the text overlaps.

How do I keep my geom_text() from getting cut off? I tried expanding the area of my graph, like this answer, but it's not working (perhaps because my text is below the graph?). I've also added line breaks to my x axis labels to give more room, but it's just not showing up.

Here's a sample:

library(dplyr)
library(ggplot2)

test <- tibble(group = c("\nA", "\nB"),
               score = c(100, 75),
               my_label = c("This group\n won the game\nYAY!", "This group\n lost the game\nBOO!"))


ggplot(test, aes(x = group, y = score)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = my_label), size = 4.7, y = -.4, vjust = 1)

enter image description here

J.Sabree
  • 2,280
  • 19
  • 48

0 Answers0