Reputation: 425
Though I have been able to get label_bquote()
to work with geom_raster()
when faceting into rows, it seemingly does not work when faceting into columns. Here is a reproducible example, where the rasters are faceted into rows, giving the correct output:
library(ggplot2)
d = expand.grid(
X = c(1, 2, 3),
Y = c(1, 2, 3),
Z = c(1, 2, 3)
)
set.seed(123)
d$A = runif(27)
p = ggplot(
data = d
) +
geom_raster(
mapping = aes(
x = X,
y = Y,
fill = A
)
) + facet_grid(
Z ~ .,
labeller = label_bquote(
"Z Value ="~ .(Z)
)
)
The output is as you would expect:
However if the facet_grid()
formula is changed to show columns instead of rows:
) + facet_grid(
. ~ Z,
labeller = label_bquote(
"Z Value ="~ .(Z)
)
)
Then the bquote labelling is ignored, and only the parsed labelling is used:
What is causing this please?
EDIT: I should have added: I am using ggplot2 version 3.1.0 from CRAN.
Upvotes: 1
Views: 373
Reputation: 36
I reported it as a bug but apparently it's not... see this issue.
label_bquote() has both rows and cols arguments! You'll need to specify which is which to get it working with facet_grid().
Or in the ggplot2 manual:
label_bquote(rows = NULL, cols = NULL, default)
Upvotes: 1