-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Length of legend title affects justification of legend keys/labels? #1903
Comments
Minimal reprex: library(ggplot2)
df <- data.frame(x = c("a", "bbbbbbbbbbbbb"))
ggplot(df, aes(x = x, fill = x)) +
geom_bar() +
labs(fill = "A very very very long label") +
theme(legend.box.just = "center") I think the current behaviour is technically correct - the title is centered, but the legend box is not. |
This SO answer provides a way to center the legend box underneath the title: One downside to this approach is that if there are multiple legends then they will be centered relative to each other but not overall. A better solution would fix the overall case as well. |
I think this reaches beyond the currently provided theme settings... The title alignment is basically doing what it should, and so does We will need a new setting that takes care of internal alignment of titles and keys with respect to each other |
This produces a nicely centred title (and centred legend text):
Here changing the length of the legend title appears to affect the justification of the legend text:
Using ggplot2_2.1.0 and R version 3.2.4 Revised
The text was updated successfully, but these errors were encountered: