[R] display UTF8 characters in pdf

Thierry Onkelinx thierry.onkelinx at inbo.be
Fri Mar 10 17:06:25 CET 2017


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]]



More information about the R-help mailing list