[英]R plotting, date on x axis
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".
我基本上想在x轴上使用格式为“%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. 谢谢。
Don't use the labels
argument when you use format
: 使用
format
时,请勿使用labels
参数:
axis.Date(1, at = seq(d[1], d[length(d)], by = "month"),
format = "%d-%m-%Y", las = 2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.