I was doing a plot with ggplot2 in which I want the names of the strips with mathematical notation. For this I used
facet_grid( factor1~ factor2, labeller = label_parsed)
but I also want the names in bold face. The problem is that once I have used the label_parsed option, I can't change the face using
theme( strip.text.x = element_text(face="bold"))
It doesn't work.
Example:
var_a <- 1:20
var_b <- 2:21
factor_a <- factor ( rep (c("a1","a2"), each = 10))
factor_b <- factor ( rep (c("b"), each = 20))
data <- data.frame (factor_a,factor_b,var_a,var_b)
## Change the name of the levels of factor_a
data$factor_a <- factor(data$factor_a, labels = c("a"~"4"^"3","a2"))
## plot 1
ggplot (data, aes (var_a, var_b)) +
geom_point () +
facet_grid (factor_a ~ factor_b, labeller = label_parsed) +
ggtitle(expression("Plot"^"exponent")) +
theme (
plot.title = element_text(face="bold"),
strip.text.x = element_text(face="bold"),
strip.text.y = element_text(face="bold")
)
## plot 2
ggplot (data, aes (var_a, var_b)) +
geom_point () +
facet_grid (factor_a ~ factor_b, labeller = label_parsed) +
ggtitle(expression(bold("Plot"^"exponent"))) +
theme (
plot.title = element_text(face="bold"),
strip.text.x = element_text(face="bold"),
strip.text.y = element_text(face="bold")
)
In plot 1, I can't make neither the strip text nor the title bold. But in plot 2 I can make the title bold.
¿How can I make the stript text bold with mathematical notation?