tags:

views:

200

answers:

2

From the online bar chart guide:

qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear)) 

alt text

How do I get 5 to sit on the bottom, 4 above that, and 3 on top?

+2  A: 
qplot(factor(cyl), data=mtcars, geom='bar', fill=factor(gear, level=5:3))
xiechao
You got it, but it's more convenient to define new `data.frame` and then run `qplot` on `transform()` ed one, hence getting clean legend and axis: `newone <- transform(mtcars, cyl = factor(cyl), gear = factor(gear, levels = 5:3))` Then: `qplot(cyl, data = newone, fill = gear)`... and the code is cleaner too!
aL3xa
+1  A: 

qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear), order = -gear)

hadley