Dear List, I would be pleased if someone can help me with the following issue: I'm about to plot two time series in one plot via ts.plot which looks like: ts.plot(series1, series2, main=main, xlab=xlab, ylab=ylab, col=c("green", "red", "blue"), lwd=2) The problem is, that R automatically sets the x axes labels in 5-year-intervalls. Every 5 years there's one tick and one label with the respective year. Now I would like to customize the axes in a way that there is a label every year and a tick every quarter. In the previous code I've determined the time series with series1 = ts(x, start=c(2000,1), frequency=4) series2 = ts(y, start=c(2000,1), frequency=4) What I've tried before is deleting the X axes via gpars=list(xaxt="n") in the ts.plot-code. But after that I was not aible to add the customized axes via axis()... In advance, thank you very much for your help and hints! Regards, Jochem Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App f?r iPhone und Android. [1]https://produkte.web.de/freemail_mobile_startseite/ References 1. https://produkte.web.de/freemail_mobile_startseite/
On Tue, Feb 28, 2012 at 12:57 PM, Jochem Schuster <jochem.schuster at web.de> wrote:>? ts.plot(series1, series2, main=main, xlab=xlab, ylab=ylab, col=c("green",> ? "red", "blue"), lwd=2)? What I've tried before is deleting the X axes via gpars=list(xaxt="n") in> ? the ts.plot-code. But after that I was not aible to add the customized axes > ? via axis()...So what was the problem? A reproducible example with your attempt at annotating the ?axis would help.> ? In advance, thank you very much for your help and hints! > ? Regards, > ? Jochem > > > ? Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App f?r iPhone > ? und Android. > ? [1]https://produkte.web.de/freemail_mobile_startseite/ > > References > > ? 1. https://produkte.web.de/freemail_mobile_startseite/ > ______________________________________________ > 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.
On Wed, Feb 29, 2012 at 1:56 AM, Jochem Schuster <jochem.schuster@web.de>wrote:> Hello, > > thank you very much for your answer. In the following, I will provide my > recent code and try to explain again: > > series1 = ts(x$france start=c(2000,1), frequency=4) > series2 = ts(x$germany, start=c(2000,1), frequency=4) > time = c(2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011) > ts.plot(series1, series2, col=c("blue", "red"), lwd=3, gpars=list(xaxt="n") >Thank you for an almost reproducible example (we don't have x and you are missing the closing ')' in plot. No worries, the problem is here:> axis(1, at=1:12, tick=1:48, labels=time, las=2) > > # series* is already of class 'ts', so in the plot the x-axis ranges >par('usr')[1:2] and "at=1:12" is out of range. I think you wanted: # x <- matrix(rt(12*4*2,3),nc=2,dimnames=list(NULL,c('france','germany'))) series1 = ts(x[,'france'], start=c(2000,1), frequency=4) series2 = ts(x[,'germany'], start=c(2000,1), frequency=4) ts.plot(series1, series2, col=c("blue", "red"), lwd=3, gpars=list(xaxt="n")) axis(1, at=seq(2000-.25,2012,.25),labels=NA) axis(1, at=2000:2012,labels=2000:2012,tcl= -.8,lwd.ticks=1.2,las=2) Hope that did it. Elai> There is no error with entering these codes. After the ts.plot command, > the x axes in the plot is deleted. > But entering the axis command, the new axes - which should display annual > labels and quarterly ticks - is not plotted. > > Thanks again for your help! > > Jochem > > > > Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App für > iPhone und Android. > *https://produkte.web.de/freemail_mobile_startseite/*<https://produkte.web.de/freemail_mobile_startseite/> >[[alternative HTML version deleted]]