Hi all, I am plotting a financial time series, but I need a more detailed X-Axis. Example: x <- zoo(rnorm(1:6000), as.Date("1992-11-11")+c(1:6000)) plot(x) The X-Axis is labeled "1995", "2000" and "2005". I would need either "1995", "1997", etc. or maybe yearly I used google first, then look at "?plot.zoo" but could't get it working. Regards, Steve
There is an example of this in the examples section of ?plot.zoo after the comment: shade a portion of a plot and make axis fancier On Sat, Jul 25, 2009 at 8:36 PM, stvienna wiener<stvienna at gmail.com> wrote:> Hi all, > > I am plotting a financial time series, but I need a more detailed X-Axis. > > Example: > x <- zoo(rnorm(1:6000), as.Date("1992-11-11")+c(1:6000)) > plot(x) > > The X-Axis is labeled "1995", "2000" and "2005". > I would need either "1995", "1997", etc. or maybe yearly > > > I used google first, then look at "?plot.zoo" but could't get it working. > > > Regards, > Steve > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
stvienna wiener schrieb:> Hi all, > > I am plotting a financial time series, but I need a more detailed X-Axis. > > Example: > x <- zoo(rnorm(1:6000), as.Date("1992-11-11")+c(1:6000)) > plot(x) > > The X-Axis is labeled "1995", "2000" and "2005". > I would need either "1995", "1997", etc. or maybe yearly > > > I used google first, then look at "?plot.zoo" but could't get it working. > > > Regards, > Steve > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >Hey, try something like the following: plot(x, y, xaxt="n") axis.Date(1, at=seq(as.Date("1960-01-01"), max(as.Date(x)), "years"), labels = FALSE, tcl = -0.2) axis.Date(1, at=seq(as.Date("1960-01-01"), max(as.Date(x)), "5 years"), labels = TRUE, las=3, tcl = -0.2) Regards, Christian [[alternative HTML version deleted]]