[R] How to switch label font from Chinese to English

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Dec 7 18:14:15 CET 2010


On Tue, 7 Dec 2010, Jianhong Wang wrote:

> Hi
>
> I tried to plot something simple
>
> x=c('2010-08-20', '2010-08-30')
> y = c(1,2)
> t = strptime(x, "%Y-%m-%d")
> plot(t,y)
>
> At the xlab, the fonts are Chinese.  How can I switch it to English?  I am
> working under Windows 7 64 bits Home Edition and R is Win32 version 2.11.1

Is this covered by the Windows FAQ at
http://cran.r-project.org/bin/windows/base/rw-FAQ.html

especially Qs 3.2 and 3.3?  (We don't know what you see in Chinese.) 
I suspect the issue is the locale category LC_TIME which is used to 
'print' date-times (and in my UK locale I get an x axis annotated ny 
'Aug').  If I do

> Sys.setlocale('LC_TIME', 'zh_CN.utf8')
[1] "zh_CN.utf8"
> plot(t,y)

I get Chinese labels ....

If so, you can also use a different format for the annotations: see 
?axis.POSIXct, e.g.

plot(t, y, format='%m/%d')


>
> Thanks!
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>

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