[R] Enhance Pairs Scatterplot Matrix
Johannes Radinger
JRadinger at gmx.at
Mon Mar 26 11:00:26 CEST 2012
Hi,
I am trying to do plot a scatterplot matrix using pairs() from
the package graphics. There are now a few things I'd like to improve
for a better understanding.
1) My scatterplot uses two log-scaled axis...as I
don't know how to set them in pairs() I calculated the log before but now
the labels are not as I want them. I'd like them as 10^1,10^2 etc.
What is the best way to handle log-scales with scatterplot matrices?
2) I use the upper panel for showing correlation coefficients instead of
the scatterplots. For these panels I don't need axis. So I'd like to concentrate my axis in the lower panel, how can that be done?
3) Is it possible to label the axis e.g with the dimensions etc.?
Here my code so far and the result is attached as pdf:
cor.resp.log <- na.omit(data.frame(log(SIGMA_STAT),p,log(SIGMA_MOB)))
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)
}
#correlation pair plot
pairs.resp <- pairs(cor.resp.log, labels=c(expression(paste('log(',sigma[stat],')')),"p",expression(paste('log(',sigma[mob],')'))),lower.panel = function(...) panel.smooth(..., col.smooth="grey"), upper.panel=panel.cor)
Thanks!
Best regards,
Johannes
--
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cor_move_factors.pdf
Type: application/pdf
Size: 11514 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120326/db84b13b/attachment.pdf>
More information about the R-help
mailing list