[R] change order of bar plot categories
Felipe Carrillo
mazatlanmexico at yahoo.com
Wed Oct 14 22:19:31 CEST 2009
Is this what you want?
temp<-c(rep("Low",2),rep("Medium",2),rep("High",2))
light<-rep(c("Dark","light"),3)
avg<-dat.avg2[,3] #
se<-dat.avg2[,4]
dat.avg.temp<-data.frame(cbind(avg,se))
dat.avg.temp<-data.frame(cbind(temp,light,dat.avg.temp))
dat.plot<-qplot(light,avg, fill=factor(temp),data=dat.avg.temp,
geom="bar", position="dodge") + scale_fill_discrete("Temp",labels=c('Low','Medium','High'))
dat.plot
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
--- On Wed, 10/14/09, Wade Wall <wade.wall at gmail.com> wrote:
> From: Wade Wall <wade.wall at gmail.com>
> Subject: change order of bar plot categories
> To: "ggplot2" <ggplot2 at googlegroups.com>
> Date: Wednesday, October 14, 2009, 12:40 PM
>
> Hi all,
>
> I am trying to change the order of bar plot categories, and
> not sure
> how to do. I am graphing temperature means (low,
> medium, and high)
> and want them in increasing temperature order, but qplot
> puts them in
> alphabetical order. Any way to manually instruct
> qplot regarding the
> order.
>
> Here is some example code. The temperatures are
> arranged in the order
> I would like them (first column).
>
> temp<-c(rep("Low",2),rep("Medium",2),rep("High",2))
> light<-rep(c("Dark","light"),3)
> avg<-dat.avg2[,3]
> se<-dat.avg2[,4]
> dat.avg.temp<-data.frame(cbind(avg,se))
> dat.avg.temp<-data.frame(cbind(temp,light,dat.avg.temp))
> dat.plot<-qplot(light,avg,
> fill=factor(temp),data=dat.avg.temp,
> geom="bar", position="dodge")
>
> Any help would be appreciated,
>
> Wade
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the
> ggplot2 mailing list.
> To post to this group, send email to ggplot2 at googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+unsubscribe at googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
> -~----------~----~----~----~------~----~------~--~---
>
>
More information about the R-help
mailing list