[R] Defining range of x and y axis in pairs()

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 18 23:28:24 CEST 2005


Your panel function is missing a ... argument, hence the difference in the 
two cases.

As to why it works, as someone once said, it does `for some value of 
"work"'.  Amongst the many places xlim gets passed is one that set the 
scale on each panel.  Another place it gets sent is to your panel 
function.

On Tue, 18 Oct 2005, Christian Zinsmeister wrote:

> Hi,
>
> I have a problem to define the range of x and y axis in pairs() for my
> scatterplots. In low-level plots I can specify that by providing xlim
> and ylim. This also works for pairs() even if warnings tell me that it
> doesn't (see below).
>
> But if I add upper.panel and/or lower.panel it doesn't work - I get an
> error message saying that there's an error in "upper.panel
> (as.vector(x[, j]), as.vector(x[, i]), ...)"!?
                                          ^^^
> I know that (according to ?pairs) graphical parameters can be passed to
> pairs() and xlim/ylim are *not* graphical parameters - I just wonder
> why it anyway works in the first case.
>
> Can anyway tell me how to adjust my pairs statement either using
> xlim/ylim in a different way or by using totally different options?
> (I'm a newbie to R)
>
>
> # This works!
> pairs(x, panel=points, xlim=c(-2,2));
>
> # This one doesn't work
> pairs(x, panel=points, xlim=c(-2,2), lower.panel=panel.cor,
> upper.panel=panel.smooth);
>
> # this is the function for lower.panel
>    panel.cor <- function(x, y)
>    {
>        usr <- par("usr"); on.exit(par(usr))
>        par(usr = c(0, 1, 0, 1))
>        txt <- cov(x, y, use="pairwise.complete.obs");
>        text(0.5, 0.5, txt);}
>   }
>
> Thanks!
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

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