0

我正在根据日期(x 轴)绘制现象的发生。问题是,在 R 中使用 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 标签是法语的。

谢谢!

4

1 回答 1

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) 

但是最好使用format参数axis.Date来设置你想要的格式。

于 2013-03-26T01:03:19.593 回答