1

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?

  • 1
    See `?plotmath` *Note that bold, italic and bolditalic do not apply to symbols, and hence not to the Greek symbols such as mu which are displayed in the symbol font. They also do not apply to numeric constants.* – mnel Apr 26 '13 at 00:58
  • reproducible example please: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/15929240#15929240 – Jonas Tundo Apr 26 '13 at 07:49

0 Answers0