2013-03-26 93 views
0

我正在根據日期(x軸)繪製現象的發生。問題是,在R中使用axis.Date函數時,日期軸是法語的。我希望它是英文的。對不起,如果這是一個簡單的問題,但我無法找到答案。axis.date在另一種語言

這就是我所做的。

date <- as.Date(c("2011/5/12","2011/5/13","2011/5/14","2011/5/15","2011/5/16","2011/5/17","2011/5/18","2011/5/19","2011/5/20","2011/5/21","2011/5/22","2011/5/23","2011/5/24","2011/5/25","2011/5/26","2011/5/27","2011/5/28","2011/5/29","2011/5/30","2011/5/31","2011/6/1","2011/6/2","2011/6/3","2011/6/4","2011/6/5","2011/6/6","2011/6/7","2011/6/8","2011/6/9","2011/6/10","2011/6/11","2011/6/12","2011/6/13","2011/6/14","2011/6/15","2011/6/16","2011/6/17","2011/6/18","2011/6/19")) 
example <- c(0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1, 1, 2, 5, 1, 3, 3, 8, 2, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 

plot(date, example,xlab="Date of birth", axes=F,ylab="", ylim=c(0,15), yaxt="n", xaxt="n",lwd= 10,type="h", cex.lab=1.2, cex.axis=1, cex=1) 
axis(2, at=seq(0,15, 5), lwd=1, cex=1) 
axis.Date(1, at=seq(as.Date("2001/5/12"), as.Date("2011/6/19"), "weeks"), cex.axis=1, lwd=1) 

但是,如果這是一個系統配置問題,您可能看不到x標籤是法文的。

謝謝!

回答

1

比如,你可以這樣做:

old.loc <- Sys.getlocale("LC_TIME") 
Sys.setlocale("LC_TIME", "English") 
axis.Date(1, at=seq(as.Date("2001/5/12"), as.Date("2011/6/19"), "weeks"), 
      cex.axis=1, lwd=1) 
Sys.setlocale("LC_TIME",old.loc) 

但最好是使用axis.Dateformat參數來設定你想要的格式。

+0

非常感謝您的回覆。對不起,我沒有注意到它是重複的。 – 2013-03-26 13:30:55

相關問題