When using the default font (sans
) in base R, symbols like μ are poorly typeset:
plot(1, xlab = bquote("I want sans font here, but serif font for:" ~ (mu * g)))
The g looks larger than the μ symbol.
Setting the font family to serif
somewhat improves this:
par(family = "serif)
plot(1, xlab = bquote("I want sans font here, but serif font for:" ~ (mu * g)))
Still not perfect, but much closer.
sans
, is it possible to change the font family mid-sentence for the symbols?plot
?If not, is there a better way to typeset μg in
plot
As it turns out, there is indeed a far simpler way to get better typeset symbols:
plot(1, xlab = "It turns out you can just use the character μ directly")
If you save with the right encoding (here I used UTF-8), many symbols can just be used directly in R code and will be printed correctly.
I hope this answer can be useful to others.