Closed
Description
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).