Dear experts,
I am trying to make a bar graph using ggplot2. I would like to define the order 
of my bars independently of alphabetical or numerical order.
How can I do that.
Here a simplified example of my code and comments(#) describing my problem:


#Code start


library(ggplot2)

bar<-ggplot(data,aes(Leaf,Av_Glands_cor,fill=Damage))



# The column "Leaf"  contains the variable C_1, C_2 and C_Cot. R always plots 
the bars in the following orders : C_1 (closest to the y-axis), C_2, C_Cot

# How do I have to modify my code that the order of the bars is: C_Cot, C_2, 
C_1?



bar+stat_summary(fun.y=mean,geom="bar",position="dodge",colour="black")+

  theme_bw()+

  theme(text = element_text(size=15),

        axis.text.x = element_text(angle=90, vjust=1))+

stat_summary(fun.data=mean_cl_normal,geom="errorbar",position=position_dodge(width=0.9),width=0.4,colour="gray65")+

labs(x="Leaf",y="Average nr. glands corrected for leaf sz.",fill="Damage")+

  scale_fill_manual(values=c("gray95", "gray75", "gray45", "black"))

#Code end


Thank you very much,
Michael Eisenring

Eisenring Michael, Msc.
PhD Student

Federal Department of Economic Affairs, Education and Research
EAER
Institute of Sustainability Sciences ISS
Biosafety

Reckenholzstrasse 191, CH-8046 Z�rich
Tel. +41 44 37 77181
Fax +41 44 37 77201
michael.eisenr...@agroscope.admin.ch<mailto:michael.eisenr...@agroscope.admin.ch>
www.agroscope.ch<http://www.agroscope.ch/>


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to