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

Bert Gunter gunter.berton at gene.com
Mon Aug 23 22:07:08 CEST 2010


This is easy to do in xyplot (latice package) via the index.cond  and
skip arguments. Don't know about ggplot though.

-- Bert

On Mon, Aug 23, 2010 at 11:02 AM, 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?
>
> Many thanks,
> Ali
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list