Problem ordering columns in barplot

Hi! I have been working on some grouped barplots using ggplot2 and had an issue with the order of the columns. The plot shows them in alphabetical order (August, July, June, May, September) instead of chronological order. Any idea on how to fix it? Here is my code and plot:

ggplot(aes(x=Date, y=Mean_PLWP, group=Species, fill=Species), data=MeanWaterPotDawnX)+
+geom_bar(position="dodge", stat="identity")+
+ylim(0, 1) +
+labs(title = "Mean PLWP per month and species",
+x = "Month of measurement",
+y = "PLWP (MPa)")

Thanks a lot!

1 Like
ggplot(aes(x=Date, y=Mean_PLWP, group=Species, fill=Species), data=MeanWaterPotDawnX) +
  geom_bar(position="dodge", stat="identity") +
  ylim(0, 1) +
  labs(title = "Mean PLWP per month and species",
       x = "Month of measurement",
       y = "PLWP (MPa)") +
  scale_x_discrete(limits=c("May", "June", "July", "August", "September"))
1 Like

Thank you very much! It works perfectly.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.