How to get `mtext ()` with partial bold text?

I would like to add text to my plot so that one letter a is highlighted in bold. I started with the following, but the result is not what I need:

plot(1:5,axes=F)
mtext(c(only a should be bold),1:1,font=2)

What to do to make only bold?

+4
source share
1 answer

Sophisticated text editing can be done with expression. See ?plotmathfor a list of commands.

mtext(expression(paste("only ", bold("a"), " should be bold")), 1, 1)

enter image description here

+8
source

Source: https://habr.com/ru/post/1537906/


All Articles