Reputation: 362
I know there are quite a few posts on plotting date values in axis. However, none seem to help. I basically want to have dates in the x-axis with the format "%d-%m-%Y". From the posts, this should be simply:
dat=read.table("TS.table",header=TRUE)
d=as.Date(dat$Date,format="%Y-%m-%d")
plot(d,1:length(d), xaxt="n", xlab="", ylab="")
axis.Date(1, at = seq(d[1], d[length(d)], by="month"),
labels= seq(d[1], d[length(d)], by="month"),
format="%d-%m-%Y", las = 2)
However, i get:
You can find the text file with the dates here.
Thanks.
Upvotes: 2
Views: 5393
Reputation: 81733
Don't use the labels
argument when you use format
:
axis.Date(1, at = seq(d[1], d[length(d)], by = "month"),
format = "%d-%m-%Y", las = 2)
Upvotes: 1