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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%