In the r
package corrplot
, you can mix the type of figure on the lower and upper half of a correlation matrix to make a nice visual. I would like t
As of corrplot
version 0.84, it is now possible to have different colour text and ellipses as documented here. For example,
corrplot.mixed(MyMatrix, lower.col = "black", number.cex = .7)
specifies that the text in the lower half of the matrix is black.
They have an example of this buried in ?corrplot
(it's under "circle + black number"). It looks like you have to call corrplot
twice: once to draw the ellipses first (in colour) and then again to draw the coefficients (specifying e.g. colour=black) separately, because if you specify col="black"
in corrplot.mixed
the ellipses will also be black.
Also if you look at corrplot.mixed
code, you can see it passes the same ...
to both the upper and lower calls, which is why specifying e.g. colour="black"
into corrplot.mixed
will draw both your ellipses and text black rather than just the text.
ie
# draw ellipses + decorations
corrplot(cormatx, type="upper", method="ellipse",
tl.pos="lt", tl.col="black", tl.offset=1, tl.srt=0)
# draw labels in black (disabling all the other stuff already drawn)
corrplot(cormatx, add=T, type="lower", method="number",
col="black", diag=F, tl.pos="n", cl.pos="n")
# if you don't like the lines on the diagonal, (ie diag="n" of corrplot.mixed),
# having a look at corrplot.mixed yields the following code:
n <- nrow(cormatx)
symbols(1:n, n:1, add=TRUE, bg="white", fg="grey", inches=F, squares=rep(1, n))
It's a bit of a pain. Essentially you are implementing corrplot.mixed
yourself, the only difference being that you can pass separate extra arguments to the upper and the lower (which corrplot.mixed
can't).