How to make plot title partly bold?

Use plotmath as documented by the R Core team and in the ggplot2 wiki.

library(ggplot2)

p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
  geom_point()

p + labs(title = bquote('This is' ~ bold('my plot')))

enter image description here


You can also use the latex2exp package:

library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
  geom_point()
p + labs(title = latex2exp::TeX("$\\alpha = 5$ text, then \\textbf{bold}"))

or

plot(0, 0, main = latex2exp::TeX("$\\alpha = 5$ text, then \\textbf{bold}"))

with the same effect but more flexibility.

Tags:

R

Ggplot2