Hello, I have a customized pairs () fonction as follows that displays correctely my data. ------------------------------------------------------------------------ panel.cor1 <- function (x, y, digits=2, prefix="") { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- cor(x, y,use="pairwise.complete.obs", method = meth) if (r>0) {alt<-"greater" } else alt<-"less" co <-cor.test(x,y,method = meth,alternative=alt)$p.value if (co<0.05 ) {colo<-"red" } else colo<-"black" txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") cex.cor <- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = abs(cex.cor * r),col=colo) } panel.line1 <- function (x, y, col = par("col"), bg = NA, pch par("pch"), cex = 1) { points(x, y, pch = pch, col = colour, bg = bg, cex = cex) ok <- is.finite(x) & is.finite(y) if (any(ok)) abline(lsfit(x,y,intercept = TRUE), col= "red" ) } pairs(temp.df, lower.panel=panel.line1,upper.panel=panel.cor1 ) ------------------------------------------------------------------------ However I decided to add a green line to my display and I was not able to do it with the pairs() function, I used insted splom(). But I dont'know how to change panel.pairs inside superpanel in order to use my panel.line1 and panel.cor1 functions. ------------------------------------------------------------------------ splom(~temp.df, aspect="fill", varnames=paste("coord", 1:10, sep=""), xlab="", pscales=0, varname.cex=0.6, cex=0.2, superpanel = function(...) { panel.pairs(...) panel.abline(h =6.5, v = 6.5, col = "green", lwd = 4) }) ------------------------------------------------------------------------ I very much appreciate if someone could help me. All the best, Isabel -- View this message in context: http://r.789695.n4.nabble.com/panel-pairs-in-splom-tp2720948p2720948.html Sent from the R help mailing list archive at Nabble.com.
Sorry, I forget to define temp.df <- sapply(1:10, function(i) rnorm(20, 0,1)) Best, Isabel -- View this message in context: http://r.789695.n4.nabble.com/panel-pairs-in-splom-tp2720948p2720968.html Sent from the R help mailing list archive at Nabble.com.
Indeed, some commands are missing. Sorry. My function is as follows, ---------------------------------------------------------------------------------------- panel.cor1 <- function (x, y, digits=2, prefix="") { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- cor(x, y,use="pairwise.complete.obs", method = meth) if (r>0) {alt<-"greater" } else alt<-"less" co <-cor.test(x,y,method = meth,alternative=alt)$p.value if (co<0.05 ) {colo<-"red" } else colo<-"black" txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") cex.cor <- 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = abs(cex.cor * r),col=colo) } panel.line1 <- function (x, y, col = par("col"), bg = NA, pch par("pch"), cex = 1) { points(x, y, pch = pch, col = colour, bg = bg, cex = cex) ok <- is.finite(x) & is.finite(y) if (any(ok)) abline(lsfit(x,y,intercept = TRUE), col= "red" ) } temp.df <- sapply(1:10, function(i) rnorm(20, 0,1)) meth<-"kendall" colour<-c(rep("blue", 20 )) pairs(temp.df, lower.panel=panel.line1,upper.panel=panel.cor1 ) ---------------------------------------------------------------------------------------- I would like to use panel.line1 and panel.cor1 inside superpanel of splom function below ---------------------------------------------------------------------------------------- require(lattice) splom(~temp.df, aspect="fill", varnames=paste("coord", 1:10, sep=""), xlab="", pscales=0, varname.cex=0.6, cex=0.2, superpanel = function(...) { panel.pairs(...) panel.abline(h =6.5, v = 6.5, col = "green", lwd = 4) }) ---------------------------------------------------------------------------------------- Best, Isabel -- View this message in context: http://r.789695.n4.nabble.com/panel-pairs-in-splom-tp2720948p2721009.html Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- Splom custom superpanels
- Lattice: How to color the data points in splom() according to the panel they are plotted?
- How to put given values in lower triangle of splom-plot?
- splom, plotmath: how to add three lines of information with alignment?
- Adding axis lines to splom plots