2

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 ?plotmath.

I noticed that using bold within the expression changes only character strings to bold face, but not numbers which are part of the expression. See this minimal example:

x <- y <- 1:10
plot(x, y, xlab=bquote(bold(foo[bar]^2==.(mean(x)))))

enter image description here

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 bold. When I change these to character strings, the plot shows them in bold.

plot(x, y, xlab=bquote(bold(foo[bar]^"2"==.(as.character(mean(x))))))

enter image description here

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

Additionally, I use Cairo 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.

Therefore, I would appreciate if there is a solution that doesn't require to change the default font in the Cairo device.

EDIT:

As mentioned in the comments, plotmath does not apply bold 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 Cairo would).

Thanks!

SimonG
  • 4,701
  • 3
  • 20
  • 31
  • tikzDevice could be what you're after; its typographic output is unmatched – baptiste Oct 09 '14 at 15:49
  • 1
    From the `?plotmath` help page: "Note that bold, italic and bolditalic do not apply to symbols, and hence not to the Greek symbols such as mu which are displayed in the symbol font. They also do not apply to numeric constants." – MrFlick Oct 09 '14 at 15:50
  • @MrFlick: I saw that too. However, somehow I assumed this would apply only to pre-defined constants like, say, `pi`. So that covers that. Is there still a solution that allows printing in bold without changing the font face for the rest of the plot? – SimonG Oct 09 '14 at 15:56
  • can font=2 be combined with plotmath? (Haven't found a way within 30 sec, gave up, sorry) – Berry Boessenkool Oct 09 '14 at 22:07

0 Answers0