[R] charset in graphics

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Jul 13 12:36:38 CEST 2007


Donatas G. wrote:
> How do I make Lithuanian characters display correctly in R graphics? 
>
> Instead of the special characters for Lithuanian language I get question 
> marks...
>
> I use Ubuntu Feisty, the locale is utf-8 ...
>
> Do I need to specify somewhere the locale for R, or - default font for the 
> graphics?
>   
You mean as in

> plot(0,main="\u104\u116\u0118\u012e\u0172\u016a\u010c\u0160\u017d")
>
plot(0,main=tolower("\u104\u116\u0118\u012e\u0172\u016a\u010c\u0160\u017d"))

?

This works fine for me on OpenSUSE 10.2, so I don't think the issue is
in R. More likely, this has to do with X11 fonts (Unicode is handled via
a rather complicated mechanism involving virtual fonts). Postscript/PDF
is a bit more difficult. See ?postscript and the reference to
Murrell+Ripley's R News article inside.

The correct incantation seems to be

postscript(font="URWHelvetica", encoding="ISOLatin7")
plot(0,main=tolower("\u104\u116\u0118\u012e\u0172\u016a\u010c\u0160\u017d"))
dev.off()

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list