Corrplot label printing

2019-08-01 15:50发布

This can be thought of as a continuum of my earlier question - R - corrplot correlation matrix division - so let's use the same example data here as well.

df <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 = rnorm(20),
                 x4 = rnorm(20), x5 = rnorm(20), x6 = rnorm(20),
                 x7 = rnorm(20), x8 = rnorm(20), x9 = rnorm(20),
                 x10 = rnorm(20), x11 = rnorm(20), x12 = rnorm(20))
cormatx <- cor(df)
corrplot(cormatx, method = "color")

Now I can alter the position of the labels by adding tl.pos = ..., which, according to the package manual, only takes "lt", "ld", "td", "d" or "n" as arguments. These are "left and top", "left and diagonal", "top and diagonal", "diagonal" and "NULL" respectively. To my knowledge all the arguments involving the "diagonal" option won't even work with method = "color".

Is there a way to print only the top labels? I tried tl.pos = "t", without any luck. I think that argument just isn't supported so it returned "default".

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-01 16:10

You can try the following hack:

df <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 = rnorm(20),
                 x4 = rnorm(20), x5 = rnorm(20), x6 = rnorm(20),
                 x7 = rnorm(20), x8 = rnorm(20), x9 = rnorm(20),
                 x10 = rnorm(20), x11 = rnorm(20), x12 = rnorm(20))
cormatx <- cor(df)
rownames(cormatx) <- rep(" ", NROW(cormatx)) # hack
corrplot(cormatx, method = "color")

enter image description here

查看更多
登录 后发表回答