0

I am trying to find a way to visualise the x-axis labels more clearly if you have crowded data. Making the labels vertical does good job. Is it possible to arrange the labels alternating to let's say the axis, so that spaces between the labels become clearer.

Example:

name = replicate(100, expr = paste(sample(LETTERS, 5), collapse = "")) value = sample(1:2000, 100, replace = TRUE) df = data.frame(name, value)

barplot using library(ggplot2)

ggplot(df, aes(name, value)) + geom_bar(stat = "identity") + theme(axis.text.x = element_text(angle = 90, hjust = 1))

It is still crowded. How can I arrange the labels alternating both up and down of the x-axis or a line below it.

enter image description here

PDM
  • 84
  • 10
  • do you mean, e.g. odd labels along the bottom margin and even labels along the top margin? – Ben Bolker Apr 17 '17 at 18:21
  • yes, that would be nice – PDM Apr 17 '17 at 18:22
  • perhaps you can adapt one of these strategies : http://stackoverflow.com/questions/39717545/add-secondary-x-axis-labels-to-ggplot-with-one-x-axis – Nate Apr 17 '17 at 19:24
  • Can you modify one of [these?](http://stackoverflow.com/questions/40942816/change-label-of-yaxis-face-in-plot-with-ggplot-package-r/40966343#40966343) – Sandy Muspratt Apr 17 '17 at 20:25
  • 1
    Thank you. I was able to modify your plot to suit my requirement. Great solution. Learned a lot. – PDM Apr 17 '17 at 22:59

0 Answers0