Skip to content
Prev 367659 / 398500 Next

display UTF8 characters in pdf

Hi,

AFAICT, you need to use a Cairo device for being able to display some 
Unicode
characters in a plot.

 From my experience, the CairoPDF() from library(Cairo) does not work
(and I don't understand the difference with cairo_pdf()), but the
cairo_pdf() from grDevices does work perfectly well for this aim. As far
as I'm concerned, I use it with both ggplot2 and regular plots and it
does a perfect job. Here is a short example:

In an R console:

cairo_pdf(filename = "test.pdf")
plot(1,1,pch = "\u254")
dev.off()

Also, I use it with knitr and it works great. You just have to declare a
specific device ("cairo_pdf").

For example, in an RMarkdown document:

```{r ipaunicode, echo=TRUE, dev='cairo_pdf'}
plot(1, 1, pch = "\u254")
```

and in a LaTeX / knitr document as well:

<<ipaunicode, dev="cairo_pdf">>=
plot(1, 1, pch = "\u251")
@

Hope this helps.

Yours.
Olivier.

On Fri, 10 Mar
2017 17:06:25 +0100 Thierry Onkelinx <thierry.onkelinx at inbo.be> wrote: