Change text color in corrplot.mixed

后端 未结 2 1424
暖寄归人
暖寄归人 2021-01-14 11:18

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

相关标签:
2条回答
  • 2021-01-14 11:59

    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.

    0 讨论(0)
  • 2021-01-14 12:14

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

    0 讨论(0)
提交回复
热议问题