[R] GGPLOT2: Reverse order of legend to match order of x-axis
Ryan Garner
ryan.steven.garner at gmail.com
Wed Mar 24 20:40:03 CET 2010
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.
More information about the R-help
mailing list