[R] change order of plot panels in faceted ggplot/qplot

Alison Macalady ali at kmhome.org
Mon Aug 23 20:02:13 CEST 2010


I have a 5-paneled figure that i made using the facet function in  
qplot (ggplot).  I've managed to arrange the panels into two rows/ 
three columns, but for the sake of easy visual comparisons between  
panels in my particular dataset, I want to have the two plots on the  
bottom align on the right hand side of the figure instead of the left.

Here's an example:
m <- matrix(rnorm(300), nrow = 60)
colnames(m) <- paste('V', 1:5, sep = '')
b <- data.frame(site = factor(rep(c('A', 'B', 'C', 'D', 'E'), each =  
12)), status = factor(rep(rep(c('D','L'), each = 3), 10)),  

qplot(V2, V1, data=b, shape=status) + scale_shape_manual(value=c(1,16)) 

What I would like to do is keep the 2 row shape, keep the order  
(A,B,C) of the top plots, but have the D and E panels in this example  
align under the B and C plots.

Is this possible using qplot?

Many thanks,

More information about the R-help mailing list