title: R: bold numbers in plot annotation created by plotmath
body: <p>I build graphics in which I use regular and bold font for titles and/or labels. They contain symbols, text and numbers which I combine using <code>?plotmath</code>.</p>
  
  <p>I noticed that using <code>bold</code> within the expression changes only character strings to bold face, but not numbers which are part of the expression. See this minimal example:</p>
  
  <pre><code>x &lt;- y &lt;- 1:10
  plot(x, y, xlab=bquote(bold(foo[bar]^2==.(mean(x)))))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/AWCtm.png" alt="enter image description here"></p>
  
  <p>In this example, there is a numeric superscript on the LHS, and an evaluated expression on the RHS of the equality sign. Both of which are not printed in bold face as suggested by using <code>bold</code>. When I change these to character strings, the plot shows them in bold.</p>
  
  <pre><code>plot(x, y, xlab=bquote(bold(foo[bar]^"2"==.(as.character(mean(x))))))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/V6Lqt.png" alt="enter image description here"></p>
  
  <p>Now, for me it is not always desirable to work with character input in these expressions. I would like to find a way of setting the numeric values in bold without converting them to character strings. (I'm also not sure what to expect of the equality sign.)</p>
  
  <p>Additionally, I use <code>Cairo</code> to select specific fonts for my graphics.
  In my actual graphics, where I also plot greek letters, I use it to set the "symbol" fonts to bold.
  By setting the "regular" font to bold, I could do the same for numbers, but that would affect all remaining text as well.</p>
  
  <p>Therefore, I would appreciate if there is a solution that doesn't require to change the default font in the <code>Cairo</code> device.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>As mentioned in the comments, <code>plotmath</code> does not apply <code>bold</code> to numeric constants as in the example above. I would still like to see if there is a solution that allows to set numbers in lables/titles to bold without changing the rest of the plot (as for example <code>Cairo</code> would).</p>
  
  <p>Thanks!</p>