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

Hadley Wickham hadley at rice.edu
Tue Aug 24 22:26:14 CEST 2010


On Mon, Aug 23, 2010 at 1:02 PM, Alison Macalady <ali at kmhome.org> wrote:
> Hi,
>
> 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)), as.data.frame(m))
>
> qplot(V2, V1, data=b, shape=status) +
> scale_shape_manual(value=c(1,16))+facet_wrap(~site,nrow=2)
>
> 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?

Not currently.

Regards,

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list