Quantcast

change order of plot panels in faceted ggplot/qplot

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

change order of plot panels in faceted ggplot/qplot

Alison Macalady
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change order of plot panels in faceted ggplot/qplot

Bert Gunter
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 <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: change order of plot panels in faceted ggplot/qplot

Hadley Wickham-2
In reply to this post by Alison Macalady
On Mon, Aug 23, 2010 at 1:02 PM, Alison Macalady <[hidden email]> 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/

______________________________________________
[hidden email] 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.
Loading...