Skip to content

Justifying the legend with respect to the full plot area rather than the panelΒ #4020

@LiRogers

Description

@LiRogers

Now that the plot titles and captions can be aligned with respect to the full plot area, it would be great if the same was true for the legend. At the moment, if the legend is positioned at the top of the plot below the title it is aligned to the plot panel, making it misaligned with the title:

library(ggplot2)

ggplot(data = diamonds, mapping = aes(x = carat, y = price, color = cut)) +
  geom_point() +
  labs(title = "A plot title") +
  theme(plot.title.position = "plot",
        legend.position = "top",
        legend.justification = "left")

Created on 2020-05-22 by the reprex package (v0.3.0)

Experimenting with negative values in legend.justification = c(x,y) can get the legend to align with the title, but the value is dependent on the size of the y-axis labels

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