[R] Order Bars in ggplot2 bar graph

michael.eisenring at agroscope.admin.ch michael.eisenring at agroscope.admin.ch
Thu Mar 19 10:06:28 CET 2015

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



# 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?



  theme(text = element_text(size=15),

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


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
Institute of Sustainability Sciences ISS

Reckenholzstrasse 191, CH-8046 Zürich
Tel. +41 44 37 77181
Fax +41 44 37 77201
michael.eisenring at agroscope.admin.ch<mailto:michael.eisenring at agroscope.admin.ch>

	[[alternative HTML version deleted]]

More information about the R-help mailing list