Reputation: 3568
This is getting very fussy now, but is there any way to italicise facet headings in ggplot2?
I have no problems getting the greek characters
i2 <- iris %>% transform(Species = factor(ifelse(Species == "setosa", "mu",
ifelse(Species == "versicolor", "sigma", "tau"))))
ggplot(i2, aes(Sepal.Width, Sepal.Length)) +
geom_point() +
facet_grid(.~Species, labeller = label_parsed)
However if I try to italicise
i3 <- iris %>% transform(Species = factor(ifelse(Species == "setosa", "italic(mu)",
ifelse(Species == "versicolor", "bold(sigma)", "tau"))))
ggplot(i3, aes(Sepal.Width, Sepal.Length)) +
geom_point() +
facet_grid(.~Species, labeller = label_parsed)
Nothing happens and it looks the same as the original plot.
Upvotes: 2
Views: 542
Reputation: 2684
Extending on @Ben Bolker comment, you can work this out using Unicode characters for the Greek letters you want to italize / make bold. This will also work in case where you might want to to this by means of italic()
or bold()
functions within expression()
calls.
In your case it is enough to replace mu
with \u03BC
, and sigma
with \u03C3
:
i3 <- iris %>% transform(Species = factor(ifelse(Species == "setosa", "italic(\u03BC)",
ifelse(Species == "versicolor", "bold(\u03C3)", "tau"))))
ggplot(i3, aes(Sepal.Width, Sepal.Length)) +
geom_point() +
facet_grid(.~Species, labeller = label_parsed)
Upvotes: 1