1

Here is what I am trying to achieve.

When designing a plot in R-project, I would like to include in the plot's legend/axes the "R" symbol for the set of real numbers with font similar to that of LaTeX's \mathbb command (i.e. the stylized way to write uppercase letters when referring to sets of real numbers, natural numbers, etc).

Would that be possible to achieve somehow? I found older questions and answers on how to use OS fonts in parts of R plots, but this alone does not solve the issue.

S08
  • 51
  • 6
  • 1
    Have you tried tikzDevice (cf https://stackoverflow.com/a/8190537/8416610) together with the mathbb LaTeX package? – Ralf Stubner Jun 04 '18 at 05:10
  • You can use the stringi package to directly call unicode characters. `library(stringi) stri_unescape_unicode(paste0("\\u","211D"))` – Esther Jun 04 '18 at 05:13
  • You can use the unicode symbol directly. However, I found I needed to use the Symbola font to get the symbol to render properly (an empty box appeared with other fonts). For example: `library(ggplot2); ggplot(mtcars, aes(mpg, wt, colour=factor(cyl))) + geom_point() + labs(x="Where x \U2208 \U211d", colour="\u211d") + theme(text=element_text(family="Symbola"))`. – eipi10 Jun 04 '18 at 05:40
  • On my Linux system I can use the Unicode code point directly `plot(1, 1, xlab = "\u211D")`. – Ralf Stubner Jun 04 '18 at 08:07
  • So did this work? – Mike Wise Jun 27 '18 at 05:25

0 Answers0