Facet labels when using facet_wrap()

2,136 views
Skip to first unread message

ucfagls

unread,
Nov 30, 2009, 9:20:25 AM11/30/09
to ggplot2
Dear Group,

I have some plotmath expressions I'd like to use as the facet labels.
I've got this all working with facet_grid(), but I'm getting the
following error with facet_wrap():

> p <- ggplot(scrs, aes(PC1, PC2, size = abundance, shape = cluster)) +
+ xlab("PC1") + ylab("PC2") +
+ facet_wrap(. ~ species, labeller = "label_parsed")
Error in get("new", env = FacetWrap, inherits = TRUE)
(FacetWrap, ...) :
unused argument(s) (labeller = "label_parsed")

This suggests facet_wrap() isn't able to handle the labeller argument.

I want to use facet_wrap as I only have a 1-d variable but want the
facets laid out on a grid to save space.

Here's a reproducible example:

set.seed(123)
spps <- factor(paste("species", sample(1:3, 10, replace = TRUE)),
levels = paste("species", 1:3),
labels = c(expression(italic(species ~ 1)),
expression(italic(species ~ 2)),
expression(italic(species ~ 3))))
DF <- data.frame(PC1 = rnorm(10), PC2 = rnorm(10),
abundance = runif(10),
species = spps,
cluster = factor(sample(1:3, 10, replace = TRUE)))
p <- ggplot(DF, aes(PC1, PC2, size = abundance, shape = cluster)) +
xlab("PC1") + ylab("PC2") +
facet_wrap(~ species, labeller = "label_parsed")
p + geom_point()

If this isn't possible, can someone suggest a work around with
facet.grid such that I can specify a new variable so I get the 3 plots
on a 2x2 grid (there will be one empty panel, lower right)

TIA

G

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

hadley wickham

unread,
Dec 1, 2009, 5:46:46 PM12/1/09
to ucfagls, ggplot2
Hi Gavin,

It's on the to do list. The only work around I can think of would be
to use grid to find the strip labels and directly modify their
contents.

Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2



--
http://had.co.nz/

Winston Chang

unread,
Nov 22, 2012, 4:09:57 AM11/22/12
to Matthew Beckers, ggplot2, ucfagls, Martin Baku
Unfortunately, it's not possible yet because it require some relatively large internal changes. If you're interested in more info, see here:

-Winston


On Thu, Nov 22, 2012 at 1:49 AM, Matthew Beckers <kiku...@gmail.com> wrote:
Also discovered this issue. I would appreciate a workaround.


On Thursday, 20 September 2012 11:21:39 UTC+1, Martin B. wrote:
Hi guys,

just stumbled across the same issue (3 years later :)). Is it still on the to-do list or has anyone come up with some good workaround?

Thanks!
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Reply all
Reply to author
Forward
0 new messages