How can I partly italicise a facet title / strip text in ggplot using ggtext

303 Views Asked by At

I want to have an expression partly italicised in a facet label in ggplot2, but I don't seem to be able to do it the way I have seen it here around.

I tried using element_markdown() as I have seen here around like this:

levels(iris$Species) <- c("look at *I. setosa*",
                          "and also at *I. versicolor*",
                          "finally, at *I. virginica*")

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) +
  geom_point() +
  facet_wrap(~Species) +
  theme(strip.text = ggtext::element_markdown())

Am I missing something?! The "*" are gone but the species are not italicised! Thank You all!

1

There are 1 best solutions below

0
usernewby9123 On

I had to update all packages related to ggplot (I updated tidyverse ), as well as ggtext (to 0.1.2), gridtext (to 0.1.5) and R itself (to 4.2.2) . Now it works :-)

Thanks to @stefan and @MrFlick