Lara Poplarski
2010-Nov-19 04:45 UTC
[R] negative axis values in image() and scalebar in cor.plot() {psych}
Dear List, I sent a related message yesterday, but did not receive it through the mailing list; on the R-help archives it reads as "An embedded and charset-unspecified text was scrubbed...". So here it is again, with the (little) progress I have made since then. Any help would be greatly appreciated! I am working with a relatively large correlation matrix (~1600*1600), which I am looking to plot with function cor.plot in package psych. cor.plot adds the scalebar as an extra column to the matrix plot, and then adds an axis with as many tick marks/labels as there are rows in the matrix. This makes the values unreadable even for relatively small matrices (e.g. 100*100). In order to make the output more readable, one would want the scalebar to have a reasonable number of tick marks/labels, say seq(from = zlim[1], to zlim[2], by = 0.1) for a given zlim, e.g. zlim=c(-1,1). So for matrix r, I have modified the relevant bit in cor.plot to ... nf <- dim(r)[2] nvar <- dim(r)[1] ... if (show.legend) { # at1 <- (0:(nf))/(nf) at2 <- seq(from = zlim[1], to = zlim[2], by = 0.1) abline(v = (nf - 0.5)/nf) axis(4, at = at2, labels = at2, las = 2, ...) } However, only values between 0 and 1 are used on the axis label. I believe this has to do with the analogous behavior in image(), for example: r <- cor(matrix(rnorm(600), 60, 100)) image(r, zlim=c(-1,1), axes=FALSE) at2 <- seq(from = -1, to = 1, by = 0.1) axis(4, at = at2, labels = at2, las = 2, cex.axis=.5) It is not clear to me from the image() help file why this would be. Could someone provide any hints on this, or on how to modify cor.plot() successfully? Many thanks in advance, Lara [[alternative HTML version deleted]]
Łukasz Ręcławowicz
2010-Nov-19 12:40 UTC
[R] negative axis values in image() and scalebar in cor.plot() {psych}
2010/11/19 Lara Poplarski <larapoplarski@gmail.com>> > In order to make the output more readable >You can just copy the style of the cor.plot. mat<-matrix(rnorm(256e4),16e2,16e2) image(cor(mat),axes=F,col= grey((dim(mat)[1]:0)/dim(mat)[1]),main="Like this") -- Mi³ego dnia [[alternative HTML version deleted]]