The R Project SVN R

Rev

Rev 74863 | Rev 75182 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74863 Rev 74871
Line 178... Line 178...
178
## (*is* device dependent [here have "a4r"-pdf]) :
178
## (*is* device dependent [here have "a4r"-pdf]) :
179
for(n in 1:nP) {
179
for(n in 1:nP) {
180
    par(mar = par("mar") + xMar)
180
    par(mar = par("mar") + xMar)
181
    plot2(at, n < nP && interAct)
181
    plot2(at, n < nP && interAct)
182
}
182
}
-
 
183
par(op)
-
 
184
 
-
 
185
 
-
 
186
##----- pairs() using verInd & horInd ----------
-
 
187
mpairs <- function(..., p=3, npp=2, main) { # p=4, npp=7 was Chris Andrews' example
-
 
188
    x <- matrix((1:(p*npp))/npp, ncol=p, dimnames=list(NULL, paste0("x", 1:p)))
-
 
189
    ## -> x \in [1/npp,.., p]  <==> ceiling(x) \in {1,2,...,p}
-
 
190
    ## the panel function
-
 
191
    mP <- function(x,y, ...) { ## really made for the 'x = ...' above
-
 
192
        j <- ceiling(mean(y)) # in 1:p
-
 
193
        points(x,y, col=ceiling(mean(x)), pch= 3*j, cex=((p-1.5)*j+1)/p, ...)
-
 
194
        g <- 1:(p-1); abline(h=g, v=g, lty=3, col="gray33")
-
 
195
    }
-
 
196
    if(missing(main))
-
 
197
        main <- if(...length()) sub("mpairs", '', deparse(sys.call()))
-
 
198
    lim <- range(x)
-
 
199
    k <- max(2, npp-2) ## bug in R(?): par(lab = c(1,1,7)) giving nonsense!
-
 
200
    op <- par(lab = c(k,k,7), oma=c(1,0,0,0)); on.exit(par(op))
-
 
201
    pairs(x, panel=mP, xlim=lim, ylim=lim, main=main, cex.main=1, ...)
-
 
202
}
-
 
203
 
-
 
204
mpairs() # 4x4 matrix of scatterplots
-
 
205
if(interAct) dev.set(if(length(dev.list()) < 2) dev.new() else dev.prev())
-
 
206
mpairs(horInd=1:2,verInd=  1:3 ) # 3x2 matrix: upper left [WRONG in R <= 3.5.0]
-
 
207
mpairs(horInd=3:2)               # 2x4: middle rows swapped
-
 
208
mpairs(           verInd=c(3,1)) # 4x2: cols 3,1
-
 
209
##
-
 
210
## now all with  'row1attop=FALSE'=======
-
 
211
if(interAct) dev.set(dev.prev())
-
 
212
mpairs(row1attop=FALSE) # 4x4 matrix of scatterplots -- perfect in R <= 3.5.0
-
 
213
if(interAct) dev.set(dev.next())
-
 
214
## a version of those above, with 'row1attop = FALSE'
-
 
215
mpairs(horInd=2:1,verInd=3:1   , row1attop=FALSE) # 3x2: *swapped* upper left
-
 
216
mpairs(horInd=c(3,1)           , row1attop=FALSE) # 2x3: swapped outer rows
-
 
217
mpairs(           verInd=c(3,2), row1attop=FALSE) # 3x2: cols 3,2