-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
cf. https://stackoverflow.com/questions/68925483/overlapping-labels-in-legend-in-ggplot
The guide_axis() function has helpful heuristics in the angle function to automatically set the hjust and vjust parameters. It would be really nice if these heuristics were also available in guide_legend(), guide_colorbar(), etc. to rotate legend labels. These could be provided with a label.angle argument to accompany the existing label.theme, label.vjust, and label.hjust arguments.
Example:
library(ggplot2)
df <- expand.grid(X1 = 1:10, X2 = 1:10)
df$value <- df$X1 * df$X2
ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value)) +
scale_fill_continuous(guide = guide_colourbar(direction = "horizontal", label.angle = 30))