3

Possible Duplicate:
Order Bars in ggplot2 bar graph

I have a large data set comprising of %coral cover in different 'Zones'. Using ggplot in R I've managed to produce the plot below, which is sooo nearly what I want!

I basically want to swap the facets (Coral.graph$Zone) around so they go; blue, yellow, green. Also, I want to swap the variables (Coral.graph$cover) around in the x axis so they read; Branching, Massive, Table.Plate, Other.Hard, Soft, Sand, Rock, Rubble, Macroalgea, Other. At the moment they are both sorted alphabetically (as I'm a new user I can't post my graph..)

Having followed the instructions in the linked answer, I'm still struggling. The linked answer lists the variables in "decreasing" order... as mine are not numerical I've tried listing them in the order I want, but my code writing is apparently inaccurate... Please help!

My code is

coralgraph <- Coral.graph
bar <- ggplot(coralgraph, aes(Coral,Cover))
bar + stat_summary(fun.y=mean, geom="bar", fill="White", colour="Black") + 
      facet_wrap(~Zone) + 
      stat_summary(fun.data= mean_cl_normal, geom= "errorbar", width=0.2) + 
      labs(x="Cover Type", y="Mean Percentage Cover") + 
      theme(legend.position="none") + 
      coord_flip()

This is my second week using R, so I'm fairly novice! Sorry if this is an obvious question!!

Community
  • 1
  • 1
Lynx85
  • 31
  • 2
  • Ordering the facets is done the same way as the bars, as in the the duplicate I pointed to: order the levels of the factor. – joran Oct 14 '12 at 18:59

0 Answers0