See here: http://learnr.wordpress.com/2010/03/23/ggplot2-changing-the-default-order-of-legend-labels-and-stacking-of-data/
Hadley On Wed, Mar 24, 2010 at 2:40 PM, Ryan Garner <ryan.steven.gar...@gmail.com> wrote: > > How do I reverse the order of the legend in a bar plot to match order of the > x-axis? In other words, I want the stacked colors of the legend to match the > stacked colors of the bar plot. I tried this, but it didn't work. > > colors <- c("5" = "red","4" = "blue","3" = "darkgreen") > p <- qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear)) > p + scale_colour_manual(name = "gear",values = colors,breaks = > c("5","4","3"),labels = c("5 speed","4 speed","3 speed")) > > http://n4.nabble.com/file/n1689526/plot.jpeg > -- > View this message in context: > http://n4.nabble.com/GGPLOT2-Reverse-order-of-legend-to-match-order-of-x-axis-tp1689526p1689526.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.