[R] charset in graphics

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jul 13 14:43:20 CEST 2007


On Fri, 13 Jul 2007, Peter Dalgaard wrote:

> 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()

The encoding should happen automagically in a Lithuanian UTF-8 locale, and 
does for me.  But suitable fonts (e.g. URW ones) are needed.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list