Okay, one simply has to use label.pos=0.5 in pairs() to get the correct behavior.
On 2012-03-02, at 09:10 , Marius Hofert wrote: > Dear Ilai, > > I tried to also adjust the diagonal panels. However, the variable names are > not > positioned correctly anymore. Do you know a solution? > > Cheers, > > Marius > > count <- 0 > mypanel <- function(x, y, ...){ > count <<- count+1 > bg <- if(count %in% c(1,4,9,12)) "#FDFF65" else "transparent" > ll <- par("usr") > rect(ll[1], ll[3], ll[2], ll[4], col=bg) > points(x, y, cex=0.5) > } > > mydiag.panel <- function(x, ...){ > ll <- par("usr") > rect(ll[1], ll[3], ll[2], ll[4], col="#FDFF65") > } > > U <- matrix(runif(4*500), ncol=4) > pairs(U, panel=mypanel, diag.panel=mydiag.panel) > > > Marius Hofert <marius.hof...@math.ethz.ch> writes: > >> Indeed, precisely what I was looking for. Many thanks, Ilai. >> >> ilai <ke...@math.montana.edu> writes: >> >>> par('bg') is not what you are looking for - it will set the bg of the >>> whole graphic device, not panels. I think you want: >>> count <- 0 >>> mypanel <- function(x, y, ...){ >>> count <<- count+1 >>> ll<- par('usr') >>> if(count %in% c(1,4,9,12)) bg<- "#FDFF65" >>> else bg<- 'transparent' >>> rect(ll[1],ll[3],ll[2],ll[4],col=bg) >>> points(x, y, cex=0.5) >>> } >>> >>> Cheers >>> >>> On Thu, Mar 1, 2012 at 4:49 PM, Marius Hofert >>> <marius.hof...@math.ethz.ch> wrote: >>>> Dear expeRts, >>>> >>>> I would like to colorize the backgrounds of a pairs plot according to the >>>> respective panel number. Here is what I tried (without success): >>>> >>>> count <- 0 >>>> mypanel <- function(x, y, ...){ >>>> count <<- count+1 >>>> bg. <- if(count %in% c(1,4,9,12)) "#FDFF65" else NA >>>> points(x, y, cex=0.5, bg=bg) >>>> } >>>> >>>> U <- matrix(runif(4*500), ncol=4) >>>> pairs(U, panel=mypanel) >>>> >>>> I also tried to set par(bg=bg.) before the call to points(), but that >>>> didn't >>>> work either. The only thing I found is that "bg=" can be used to fill >>>> certain >>>> plot symbols, but I would like to colorize the background of each panel, >>>> not >>>> the drawn circles. >>>> >>>> Cheers, >>>> >>>> Marius >>>> >>>> ______________________________________________ >>>> R-help@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. ______________________________________________ R-help@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.