Corrplot label printing

牧云@^-^@ 提交于 2019-12-13 19:30:22

问题


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:


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



来源:https://stackoverflow.com/questions/30207260/corrplot-label-printing

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