Search code examples
rtextr-grid

grid.text fails to display bold expression


I'm trying to add bold text to a lattice plot using grid.text. When I'm supplying 'character' labels, everything works just fine. However, when I try to add an expression (in this case including Greek symbols), the text is not bold. Any help on that would be highly appreciated.

library(grid)

grid.newpage()
grid.text("Delta (no expression)", x = .5, y = .6, gp = gpar(fontface = "bold"))
grid.text(expression(Delta ~ "(expression)"), gp = gpar(fontface = "bold"))

bold_non-bold_grid.text


Solution

  • You can put the expression directly in bold:

    grid.text(expression(bold(Delta ~ "(expression)")))
    

    enter image description here