Change text color in corrplot.mixed

戏子无情 提交于 2019-12-01 09:17:35

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).

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!