rplotfontsplotmathtypesetting

Poorly typeset μ symbol in plotmath


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)))

sans

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)))

serif

Still not perfect, but much closer.


Solution

  • 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.