简体   繁体   English

如何在R中更改x轴的频率

[英]How to change the frequency of x-axis in R

I have been working on this project for a week now and am finally plotting my data. 我已经在这个项目上工作了一个星期,现在终于可以绘制我的数据了。 I want it to display every month name in a vertical fashion instead of just displaying January. 我希望它以垂直方式显示每个月的名称,而不只是显示一月。

Heres my code 这是我的代码

plot(dates,as.zoo(dfWkly$ScvCorr26), type="l", xlab="Weeks", ylab=" ",  main = "26 and 52 Week Tracking Errors (%)",col = "red", xaxt="n", axes = FALSE, las= 1)
lines(dates, as.zoo(dfWkly$ScvCorr52), col = "green")
axis.Date(1, dates, format = "%b", las=2)
axis(2, at = seq(0 , 1, .001) )
grid (10,20, lty = 6, col = "lightgrey")

My theory: It won't change the intervals because of the format I have it in, at least not the way I normally change the intervals. 我的理论:不会因为我使用的格式而更改间隔,至少不会像我通常更改间隔的方式那样。 (with at = seq(......) (at = seq(......)

So the question. 那么问题来了。 How can I get it to display abbreviations vertically and have every month appear? 如何获得垂直显示缩写并每月显示的缩写?

Thanks for your help! 谢谢你的帮助!

-NealC -尼尔

Answer - 答案-

I had to use the date function (not sure if function or package) inside this line. 我必须在此行中使用date函数(不确定函数还是包)。

at=seq(as.Date("2007-12-31"),max(dates),by=(13*7))

对于那些来自Google的用户,我必须在此行内使用date函数(不确定是base还是package)。

at=seq(as.Date("2007-12-31"),max(dates),by=(13*7))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM