Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature Request: Axis Text Warning or Automatic Rotation when Labels Overlap #3281
I sometimes work with data where the axis text may overlap, and it would be helpful if ggplot either warned when the axis text overlapped or even better could automatically adjust rotation and justification when overlap occurs.
library(ggplot2) data_with_long_names <- data.frame( A=c(paste0(rep(LETTERS, 3), collapse=""), paste0(rep(letters, 3), collapse="")), B=1 ) # Feature request: This gives a warning ggplot(data_with_long_names, aes(x=A, y=B)) + geom_point()
# Option for consideration as an interface to automatically fix the issue #ggplot(data_with_long_names, aes(x=A, y=B)) + # geom_point() + # theme(axis.text.x.overlap=element_text(angle=45, hjust=1))
Created on 2019-04-30 by the reprex package (v0.2.0).
referenced this issue
Apr 30, 2019
Referencing #3322 as I'm working on this today as part of that project. The current strategies I think that I can build in to the current axis function relatively easily are (1) smart ordering of the labels and using
@paleolimbot Have you thought about how you want the user to turn on or off/customize this? I think ideally it would be encapsulated into a new element type, so that it can be all customized by setting the appropriate element type and arguments in the theme.
The reason why rotated labels are difficult is because we don't have enough parameters to specify how rotation should be performed. Just
For an example of the need for more parameters, see the readme here:
Right now there's no way to get any extra information to
It's currently possible to get rotated axis labels looking good at any angle with a very complicated combo of