Change order facet_wrap

338 views
Skip to first unread message

Yann Hautier

unread,
May 25, 2010, 5:22:07 AM5/25/10
to ggp...@googlegroups.com
Hi,

Here is my question.

I am drawing a graph with 8 panels with qplot and use the function facet_wrap to maximize the graph space:
facet_wrap(~ Site, ncol = 3)
The graph structure by default is the following (p.116 ggplot2 book):
1   2   3
4   5   6
7   8   9
But if there is only 8 panels to draw, then the last panel is empty (only 8 sites not 9) but still
the labels (ticks and numbers) are shown for this empty panel (as the example in p.121 ggplot2 book).
Is it possible to change the order by which the grids are filled (so that the empty panel will be the upper right one, without ticks and numbers)?  For example.

7   8   9
4   5   6
1   2   3

Or is it possible to remove the ticks and numbers of a selected panel?

Thank you in advance.

Yann

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Ben Bolker

unread,
May 25, 2010, 10:29:06 AM5/25/10
to Yann Hautier, ggp...@googlegroups.com

Yann Hautier wrote:
> Hi,
>
> Here is my question.
>
> I am drawing a graph with 8 panels with qplot and use the function
> facet_wrap to maximize the graph space:
>
> facet_wrap(~ Site, ncol = 3)
>

> But if there is only 8 panels to draw, then the last panel is empty (only 8 sites not 9) but still
> the labels (ticks and numbers) are shown for this empty panel (as the example in p.121 ggplot2 book).
> Is it possible to change the order by which the grids are filled (so that the empty panel will be the upper right one, without ticks and numbers)? For example.
>
> 7 8 9
> 4 5 6
> 1 2 3
>

d =
data.frame(x=runif(800),y=runif(800),f=factor(rep(LETTERS[1:8],each=100)))

library(ggplot2)

ggplot(d,aes(x=x,y=y))+
geom_point()+
facet_wrap(~f,ncol=3)

ggplot(d,aes(x=x,y=y))+
geom_point()+
facet_wrap(~f,ncol=3,as.table=FALSE)

appears to do the trick.


signature.asc
Reply all
Reply to author
Forward
0 new messages