简体   繁体   中英

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(......)

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.

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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