 panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
     {
         usr <- par("usr"); on.exit(par(usr))
         par(usr = c(0, 1, 0, 1))
				t<-cor.test(x, y, meth="s")
         r <- abs(t$estimate)
         txt <- format(c(r, 0.123456789), digits=digits)[1]
         txt <- paste(prefix, txt, sep="")
         if(missing(cex.cor)) cex <- 0.75/strwidth(txt)
					text(0.5, 0.9, "Test de corrélation \n de Spearman", cex=.9)
         text(0.5, 0.5, txt, cex = cex * abs(r))
					text(0.5, 0.1, paste("Probabilité :", format(c(t$p.value), digits=digits)))
     }

panel.hist <- function(x, ...)
     {
         usr <- par("usr"); on.exit(par(usr))
         par(usr = c(usr[1:2], 0, 1.5) )
         h <- hist(x, plot = FALSE)																		
         breaks <- h$breaks; nB <- length(breaks)
         y <- h$counts; y <- y/max(y)
					text(usr[2]/2,1.42, paste("Test de Shapiro-Wilks : ", round(shapiro.test(x)$p.value,3)), cex=.7)
         	rect(breaks[-nB], 0, breaks[-1], y, border="dimgray", col="lightgray", ...)
					lines(lowess(breaks[-nB],y, f=10/22, iter = 3), col="black")
				box()
     }

panel.smooth <- function (x, y, col = "dimgray", bg = NA, pch = par("pch"), cex=.5, col.smooth = "black", span = 2/3, iter = 3, ...)
{
    points(x, y, pch = pch, col = col, bg = bg, cex = cex)
    ok <- is.finite(x) & is.finite(y)
    if (any(ok))
        lines(stats::lowess(x[ok], y[ok], f = span, iter = iter),
            col = col.smooth, ...)
}

mypairs <- function(...) {
	pairs(..., diag.panel=panel.hist, upper.panel=panel.smooth, lower.panel=panel.cor)
}

#vim: encoding=utf-8 fileencoding=utf-8
