[R] [FORGED] display UTF8 characters in pdf

Paul Murrell paul at stat.auckland.ac.nz
Sun Mar 12 20:45:38 CET 2017


Hi

This does not help with a solution, but ...

The standard PDF device only does single-byte character sets (sbcs in 
the warning message).  The conversion from a multi-byte character set 
(mbcs), which is what UTF8 is, will only work if the characters map to a 
single-byte character set (things like ASCII, Latin1, etc).  The 
A-acute, probably the copyright sign, and maybe even the k-in-a-circle 
might survive the conversion, but a little drawing of a car does not.

Paul

On 11/03/2017 5:06 a.m., Thierry Onkelinx 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.
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list