powered by
Reverses the order of entries in all legends. Useful when the natural data order doesn't match the desired visual order (e.g., when stacking bars).
legend_reverse()
A guides specification that can be added to a plot.
This function applies guide_legend(reverse = TRUE) to all common discrete aesthetics: colour, fill, shape, size, linetype, and alpha.
guide_legend(reverse = TRUE)
legend_wrap, legend_style
legend_wrap
legend_style
library(ggplot2) # Default order p1 <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) + geom_point() # Reversed order p2 <- p1 + legend_reverse()
Run the code above in your browser using DataLab