在 R 中绘制 x 轴上带有日期的图表
我正在尝试在 x 轴上绘制日期,间隔为 1 个月,并旋转日期值以确保清晰。
r=runif(100)
d <- as.Date("2001/1/1") + 70*sort(r)
plot(d,r,type="l",xaxt="n")
axis.Date(1, at=seq(d[1],d[100],"month"), format="%m/%d/%Y")
这确实行不通。我试图获得类似于下图的内容:
I am trying to do a plot with date on x-axis with an interval of 1 month and date values rotated for clarity.
r=runif(100)
d <- as.Date("2001/1/1") + 70*sort(r)
plot(d,r,type="l",xaxt="n")
axis.Date(1, at=seq(d[1],d[100],"month"), format="%m/%d/%Y")
This doesn't really work. I am trying to get something similar to the following graph:
它完全按照您要求函数执行的操作。
三个月,三刻。
试试这个。
它应该很容易调整为周/月/年。您可以自行决定如何使用
?par
中的mar
参数。It does exactly what you ask the function to do.
Three months, three ticks.
Try this.
It should be easily adjusted to week/month/year. It's up to you to play with the
mar
parameter in?par
.