[R] Scatterplot matrix with partly transformed axis
Johannes Radinger
JRadinger at gmx.at
Tue Apr 10 16:10:34 CEST 2012
Hi,
I am wondering if anybody has experience with
scatterplot matrices where some (but NOT all) axis
are transformed and the labels are nicely plotted.
So far I looked into
1) pairs()
2) scatterplotMatrix() from package 'car'
3) splom() from packagae 'lattice'
4) plotmatrix() from 'ggplot2'
I can see no easy way to get what I want which is:
*) a scatterplot matrix of three variables
*) 2 of 3 variables should be log-transformed
*) the labels for the log transformed variables should be e^2 etc resp. 10^2 etc.
*) the variable names in the diagonal panel
*) no need for any densities
*) Correlation coefficients in the upper panel
I am not sure what is the best way to go to get a nice scatterplot matrix to publish...
One example with pairs() so far...but I didn't get the log scales and the labels:
panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.5/strwidth(txt)
test <- cor.test(x,y)
# borrowed from printCoefmat
Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
text(0.5, 0.5, paste(txt,Signif), cex = 2)
}
# Test with data
data(iris)
pairs(iris[1:3], lower.panel = function(...) panel.smooth(..., col.smooth="grey"), upper.panel=panel.cor)
Maybe someone can help me here as I think this is also helpful to others with a similar kind of problem.
Best regards,
Johannes
--
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
More information about the R-help
mailing list