Skip to content
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

Reverse Legend Order #47

Open
thomas-neitmann opened this issue Apr 11, 2020 · 0 comments
Open

Reverse Legend Order #47

thomas-neitmann opened this issue Apr 11, 2020 · 0 comments

Comments

@thomas-neitmann
Copy link
Contributor

When creating a horizontal grouped bar chart the order in the legend does not match the order of the bars in the plot.

library(ggplot2)
library(dplyr)

p <- mtcars %>%
  group_by(cyl, am) %>%
  summarise(n = n()) %>%
  ggplot(aes(cyl, n, fill = factor(am))) +
  geom_col(position = "dodge") +
  coord_flip()

image

Changing this involves some functions I almost never use (and thus always forget).

p + guides(fill = guide_legend(reverse = TRUE))

image

My proposal is to have something like easy_reverse_legend(). What do you think @jonocarroll?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant