[R] Coordinate scales for pairs plot

David Winsemius dwinsemius at comcast.net
Wed Aug 21 21:08:29 CEST 2013


On Aug 21, 2013, at 10:30 AM, (Ted Harding) wrote:

> Greetings all.
> 
> I suspect this question has already been asked. Apologies
> for not having taced it ...
> 
> In the default pairs plot produces by the function pairs(),
> the coordinate scales alternate between top and bottom and
> right and left sides.
> 
> For example, in a 5x5 plot for variables X1, X2, X3, X4, X5
> the coordinate scales for X2, X4 appear beside rows 2 and 4
> on the left, and the scales for X1, X3, X5 appear beside rows
> 1, 3, 5 on the right.
> 
> Similarly, the scales for X2 and X4 appear above columns 2 and 4,
> and the scales for X1, X3, X5 appear below columns 1, 3, 5.
> 
> Is there a parameter lurking somewhere in the depths of this
> function which can be set so that the scales for all the variables
> X1,X2,X3,X4,X5 appear both above and below  columns 1,2,3,4,5;
> and both to the left and to the right of rows 1,2,3,4,5?

I've searched for a parameter and come up empty; Hacking the code for pairs.default is not that difficult. I stripped out the conditionals that were driving the Axis calls to alternating "sides": 
Search for `box()` to start this surgery and replace everything to the 'mfg' assignment to get uniform axis locations on sides 1 and 2.

pairs.12 <- function(x, ... arglist same as pairs.default)
   {....upper portion of code
    box()
            if (i == nc ) 
                localAxis(1L , x[, j], x[, i], 
                  ...)
            if (j == 1 ) 
                localAxis(2L, x[, j], x[, i], ...)

    mfg <- par("mfg")
   lower portion of code ....}

Oooops,  that wasn't what you asked for ... Use this instead:

........
box()  # begin surgery
            if (i == 1 ) 
                localAxis(3, x[, j], x[, i],  ...)
            if (i == nc ) 
                localAxis(1, x[, j], x[, i],  ...)
            if (j == 1 ) 
                localAxis(2L, x[, j], x[, i], ...)
            if (j == nc ) 
                localAxis(4L, x[, j], x[, i], ...)
        # end anastomosis
 mfg <- par("mfg")
..........
--
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list