-2

I am attempting to make a multiple line chart in R using ggplot and am trying to figure out how to not have the x-axis labels overlap (something that looks like th first image below): enter image description here

This is my code: enter image description here

This is the output of my code: enter image description here

Is there a function or parameter to adjust the placement of the x-axis labels to be adjusted like the first image?

  • Check this: https://stackoverflow.com/questions/21878974/wrap-long-axis-labels-via-labeller-label-wrap-in-ggplot2 – Nicolás Velasquez Mar 13 '23 at 19:53
  • You could also try with `scale_x_discrete(guide = guide_axis(n.dodge = 2))` to place the labels in multiple rows as in the image you posted. – stefan Mar 13 '23 at 20:17
  • Check out these links stackoverflow.com/tour and https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example as this will help people to answer you question – L Tyrone Mar 13 '23 at 23:03
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 14 '23 at 11:04

1 Answers1

1

One idea you could try is to rotate the x axis labels instead of staggering them:

your_plot + theme(axis.text.x = element_text(angle = 90, hjust = 0, vjust = 0))

This related question has other ideas: ggplot2 stagger axis labels

Tyler
  • 336
  • 1
  • 7