ggeasy
ggeasy copied to clipboard
Reverse Legend Order
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()

Changing this involves some functions I almost never use (and thus always forget).
p + guides(fill = guide_legend(reverse = TRUE))

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