[R] how to pairs plot without axes

Witold E Wolski wewolski at gmail.com
Wed Oct 9 11:34:57 CEST 2013


In the pairs help is an example how to plot the correlation as txt.
How do I get rid of the axes
in the upper panel?

regards



## put (absolute) correlations on the upper panels,
## with size proportional to the correlations.
panel.cor <- function(x, y, digits = 3, prefix = "", cex.cor,axis=F, ...)
{
  tt<-cbind(x,y)
  idx<-apply(tt,1,function(x){sum(is.na(x))==0})
  x<-x[idx]
  y<-y[idx]
  usr <- par("usr"); on.exit(par(usr))
  par(usr = c(0, 1, 0, 1))
  r <- abs(cor(x, y))
  print(r)
  txt <- format(c(r, 0.123456789), digits = digits)[1]
  txt <- paste0(prefix, txt)
  if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
  text(0.5, 0.5, txt, cex = r^20*cex.cor)
}


-- 
Witold Eryk Wolski



More information about the R-help mailing list