[R] display UTF8 characters in pdf

Ista Zahn istazahn at gmail.com
Fri Mar 10 21:13:05 CET 2017


install.packages("emojifont")
library(emojifont)

... # plot as before.

Best,
Ista

On Fri, Mar 10, 2017 at 11:06 AM, Thierry Onkelinx
<thierry.onkelinx at inbo.be> wrote:
> Dear all,
>
> I'd like to use some UTF-8 characters in a plot. Some of them are not
> rendered with saving the plot as pdf. Any suggestions?
>
> library(ggplot2)
> symbols <- c("\U1F697", "\U00A9", "\U24DA", "\U00C1")
> test <- data.frame(
>   x = seq_along(symbols) %% ceiling(sqrt(length(symbols))),
>   y = ceiling(seq_along(symbols) / ceiling(sqrt(length(symbols)))),
>   symbol = symbols
> )
> p <- ggplot(test, aes(x = x, y = y, label = symbol)) + geom_text(size = 10)
> p
> ggsave(p, file = "test.png")
> ggsave(p, file = "test.pdf")
>
> The last command gives several similar warnings, all related to the symbols
> which are not rendered properly:
>
> Warning messages:
> 1: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label),  ... :
>   conversion failure on '��' in 'mbcsToSbcs': dot substituted for <f0>
>
> I'm running R 3.3.2 under Ubuntu 16.04.1 and ggplot2 2.2.1
>
> Best regards,
>
> Thierry
>
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list