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.