0

I am plotting the occurence of a phenomenon according to date (x axis). The problem is that, while using the axis.Date function in R, the date axis is in french. I would like it to be in english. Sorry if it's an easy question, but I was not able to find the answer.

Here's what I did.

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)

But if it's a system configuration problem, you might not see that the x label is in french.

Thank you!

J.VDW
  • 101
  • 2
  • 9

1 Answers1

1

You can do this for example :

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) 

But it is better to use the format argument of axis.Date to set the format you want.

agstudy
  • 119,832
  • 17
  • 199
  • 261