[R] Multiple lag.plots per page

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jun 14 06:46:56 CEST 2006

On Wed, 14 Jun 2006, Gad Abraham wrote:

> Prof Brian Ripley wrote:
>> On Tue, 13 Jun 2006, Gad Abraham wrote:
>>> Prof Brian Ripley wrote:
>>>> On Tue, 13 Jun 2006, Gad Abraham wrote:
>>>>> Hi,
>>>>> I'm trying to plot several lag.plots on a page, however the second plot
>>>>> replaces the first one (although it only takes up the upper half as it
>>>>> should):
>>>>> par(mfrow=c(2,1))
>>>>> a<-sin(1:100)
>>>>> b<-cos(1:100)
>>>>> lag.plot(a)
>>>>> lag.plot(b)
>>>>> What's the trick to this?
>>>> lag.plot itself calls par(mfrow).  The trick is to get one call to do the 
>>>> plots you want:
>>>> lag.plot(cbind(a,b))
>>> Thanks, that works great for multiple lag.plots. Is it possible to have a 
>>> lag.plot and another type of plot on the same page? The second plot() 
>>> always replaces the lag.plot for me.
>> Yes, if the other plot is second, e.g
>> par(mfrow=c(2,1))
>> a<-sin(1:100)
>> lag.plot(a)
>> par(mfg=c(2,1)) # move to second plot
>> plot(1:10)
> Following from my previous questions, lag.plot doesn't recognise some of the 
> standard plot variables, e.g. xaxt="n" doesn't remove the x-axis, and setting 
> xlab causes an error:
>> lag.plot(sin(1:100), xlab="foo")
> Error in plotts(x = x, y = y, plot.type = plot.type, xy.labels = xy.labels, 
> :
>        formal argument "xlab" matched by multiple actual arguments
> Is this a bug or a feature?

feature.  Note that the help page says

      ...: Further arguments to 'plot.ts'.

and not `graphical parameters'.

> Also, how can I make lag.plot behave nicely when plotted with other plots on 
> the same page? it takes up more room than it's allocated by par(mfrow).

Really you are not using it for its intended purpose, multiple plots at 
different lags.  (Notice the plurals in the title and the description 
on the help page.)  Why not use plot.ts directly?

If you want to pursue lag.plot, try the version in R-devel which works 
better for single-plot displays.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list