Skip to content

Permit guide_axis() angle heuristics in guide_legend(), etc. #4594

@bwiernik

Description

@bwiernik

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions