问题
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