r - Corrplot:不打印每个文本标签
问题描述
我正在使用他们的小插图中的示例,但实际上,我的相关矩阵要大得多,因此文本标签在图上不清晰。我的愿望不是打印相关图上的每个文本标签。
M <- cor(mtcars)
corrplot(M, diag = FALSE, method = "ellipse", type = "upper", tl.col = "black")
有没有办法不打印图中的每个文本标签?我想打印所有其他标签。
或者,为了阅读情节,我想使用变量组作为唯一的文本标签。从聚类中,我发现数据中可能有 3 个组。
#Reorder data collected in mtcars in this way:
mtcars2 <- mtcars[ , c("carb", "wt", "hp", "cyl", "disp",
"qsec", "vs",
"mpg", "drat", "am", "gear")
]
#Let's say I have the following groups corresponding to these variables
groups <- c(rep("Engine", 5), rep("Speed", 2), rep("Fuel", 4) )
R <- cor(mtcars2)
colnames(R) <- groups
我想在 corrogram 的顶部唯一地打印这些组名。现在,它们为每个变量打印。再说一次,我可以只为一组变量打印一次组名(“Engine”、“Speed”、“Fuel”)吗?
corrplot(R, diag = FALSE, method = "ellipse", type = "upper", tl.col = "black")
实际上,我正在使用的相关图看起来像这样。
set.seed(234)
A <- matrix(rnorm(1e+05), ncol = 100, dimnames = list(NULL, paste0("VeryLongName", 1:100)))
corrplot(cor(A), diag = FALSE, method = "ellipse", type = "upper")
该选项tl.cex = 0.5
确实有效,但我更喜欢使用更大更少的标签。
总之,我想调整corrplot()
为(1)打印每隔一个标签或(2)在轴上唯一地打印组。
这项工作是使用 corrplot 0.84 版完成的。
解决方案
也许包括空字符串groups
require(corrplot)
#Reorder data collected in mtcars in this way:
mtcars2 <- mtcars[ , c("carb", "wt", "hp", "cyl", "disp",
"qsec", "vs",
"mpg", "drat", "am", "gear")
]
#Let's say I have the following groups corresponding to these variables
groups <- c("","Engine",rep("", 3), "Speed","", "Fuel",rep("", 3) )
rows <- c("Engine","",rep("", 3), "Speed","", "Fuel",rep("", 3) )
R <- cor(mtcars2)
colnames(R) <- groups
rownames(R) <- rows
corrplot(R, diag = FALSE, method = "ellipse", type = "upper", tl.col = "black")
推荐阅读
- rx-java - 使用来自另一个 observable 的数据
- python - Django 自定义用户 CustomUserManager 不会保存我的额外数据字段
- html - Unordered list inside table using FLWOR
- javascript - 如何按比例调整“div”的背景图像大小?
- python - 将现有 sqlite3 数据库添加到 Django App
- javascript - 如何表现不同在一种模式中?
- reactjs - 在同一个html页面上调用react js的两个不同组件
- css - 图像推/浮动到边缘
- ionic-framework - 错误 ng.cmd run app:build:production exited with exit code 127
- java - 处理谷歌发布的 JWT 令牌,来自 Spring-Boot 应用程序