Possible Duplicate:
Order Bars in ggplot2 bar graph
I edited this considerably after closed. (Thank you Andrie for the advice.)
(1) Problem
The order of the labels are autumn, spring, summer, winter. How do you make them ordered as spring, summer, autumn, winter?
Problem Code:
ssn <- c("spring", "summer", "autumn", "winter")
cnt <- c(2,4,3,7)
d <- data.frame(season=ssn, count=cnt)
library(ggplot2)
ggplot() + geom_bar(data=d,aes(x=season, y=count))
(2) Solution
Solution Code:
ssn <- c("spring", "summer", "autumn", "winter")
ssn <- factor(ssn, level=ssn)
cnt <- c(2,4,3,7)
d <- data.frame(season=ssn, count=cnt)
library(ggplot2)
ggplot() + geom_bar(data=d,aes(x=season, y=count))
The 2nd line does the trick.