Steffen Fleischer
2011-Jan-24 17:11 UTC
[R] pairs(), no axis labels/values for upper panel?
Dear all, I want to draw a graph that contains the scatterplot matrix in the lower panel and coefficients in the upper panel. I used and adapted the example for the function pairs but cannot figure out how to get no values and ticks in the upper panel (the values should only be in the lower panel). The upper panel looks odd to me this way. Any hints? Thanks in advance Steffen Here is an example what the graph looks like: ############################################# data(mtcars) panel.cor <- function(a, b, digits=2, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) x<-cbind(a,b) x<-na.omit(x) n <- nrow(x) pp <- c(0.025, 0.975) corx <- cor(x,method="s")[1, 2] CI<-c(tanh(atanh(corx) + qnorm(pp)/sqrt((n - 3)/1.06))) txt1 <- paste("rho =",format(c(corx, 0.123456789), digits=digits)[1]) txt2<-paste("(",format(c(CI,0.123456789)[1],digits=digits),"; ",format(c(CI,0.123456789)[2],digits=digits),")",sep="") txt3<-paste("N =",round(n,0)) txt <- paste(txt1,"\n","95%KI ",txt2,"\n",txt3, sep="") text(0.5, 0.5, txt,cex=.8) } diag.cor<-function(a,b, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0,1)) rect(0,0,1,1,col="grey") } pairs(mtcars[1:4],upper.panel=panel.cor,diag.panel=diag.cor,label.pos=0.5) #############################################
Steffen, Did you ever have luck getting rid of the tick marks?... I like your idea and have modified it, but yes, the tick marks need to go. Steffen Fleischer wrote:> > Dear all, > > I want to draw a graph that contains the scatterplot matrix in the lower > panel and coefficients in the upper panel. I used and adapted the example > for the function pairs but cannot figure out how to get no values and > ticks in the upper panel (the values should only be in the lower panel). > The upper panel looks odd to me this way. Any hints? > > Thanks in advance > Steffen > > > Here is an example what the graph looks like: > ############################################# > data(mtcars) > panel.cor <- function(a, b, digits=2, ...) > { > > usr <- par("usr"); on.exit(par(usr)) > par(usr = c(0, 1, 0, 1)) > x<-cbind(a,b) > x<-na.omit(x) > n <- nrow(x) > pp <- c(0.025, 0.975) > corx <- cor(x,method="s")[1, 2] > CI<-c(tanh(atanh(corx) + qnorm(pp)/sqrt((n - 3)/1.06))) > txt1 <- paste("rho =",format(c(corx, 0.123456789), > digits=digits)[1]) > txt2<-paste("(",format(c(CI,0.123456789)[1],digits=digits),"; > ",format(c(CI,0.123456789)[2],digits=digits),")",sep="") > txt3<-paste("N =",round(n,0)) > txt <- paste(txt1,"\n","95%KI ",txt2,"\n",txt3, sep="") > text(0.5, 0.5, txt,cex=.8) > } > > diag.cor<-function(a,b, ...) > { > usr <- par("usr"); on.exit(par(usr)) > par(usr = c(0, 1, 0,1)) > rect(0,0,1,1,col="grey") > } > > pairs(mtcars[1:4],upper.panel=panel.cor,diag.panel=diag.cor,label.pos=0.5) > ############################################# > > ______________________________________________ > R-help@ 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. >-- View this message in context: http://r.789695.n4.nabble.com/pairs-no-axis-labels-values-for-upper-panel-tp3234437p4075283.html Sent from the R help mailing list archive at Nabble.com.