[英]R Corrplot: change color of column text labels but not row text labels
I'm using the corrplot
function to create a visualisation of beta coefficients on 4 x variables and 12 y variables. 我正在使用
corrplot
函数在4 x变量和12 y变量上创建beta系数的可视化。 Below is the code I have used so far: 以下是我到目前为止使用的代码:
library(corrplot)
corrplot(beta_m, is.corr=FALSE, method="square",
tl.srt=65, tl.cex=0.95, number.cex=0.8, tl.col='black', cl.length
= 5, cl.align="l")
This is the data where it comes from: 这是数据的来源:
beta_m<-structure(c(0, 0, -0.584090272222348, 0, 0, 0.11291756016558,
-0.435893170100887, 0, 0, 0, -0.460227704153223, 0, 0,
0.222130737988377,
0, 0.0974747494000928, 0, 0.117470450053172, -0.723935606930726,
0, -0.308146541461676, 0, 0, 0, 0, 0.153128826514138, 0, 0, 0,
0, -0.360425453158442, 0, 0, 0, -0.508415520561608, 0,
-0.303599419688516,
0, 0, 0, 0, 0, -0.551430826126704, 0, 0, 0, 0, 0), .Dim = c(4L,
12L), .Dimnames = list(c("Sex: Female", "Age", "IM: MVA", "LOC
duration: < 5 min"
), c("PDGF", "$ paste(MIP-1,beta)", "$ paste(TNF,-alpha)", "IP-10",
"Eotaxin", "FGF-basic", "IL-1ra", "IL-9", "MCP-1", "IL-17A",
"IL-8", "$ paste(IFN,gamma)")))
And this is what it currently looks like: 这是当前的样子:
What I need is for some of column labels (the 12 labels on the top) to be different colours, while the 4 row labels remain black. 我需要使某些列标签(顶部的12个标签)具有不同的颜色,而4行标签保持黑色。 The tl.col argument changes both row and column label colours.
tl.col参数更改行和列标签的颜色。
Edit: It could also work if some of the column labels are bold and others are not. 编辑:如果某些列标签为粗体,而另一些则不是,则也可以使用。
One solution is like this: 一种解决方案是这样的:
tl.col="red"
. tl.col="red"
的情况下绘制图片。 beta_m
for those columns you want to remain red. beta_m
删除要保留为红色的那些列的名称。 tl.col="black"
. tl.col="black"
在顶部添加第二张图片。 Here is a demonstration: 这是一个示范:
corrplot(beta_m, is.corr=FALSE, method="square", tl.srt=65, tl.cex=0.95, number.cex=0.8,
tl.col='red', cl.length = 5, cl.align="l")
colnames(beta_m)[5:7] <- ""
corrplot(beta_m, is.corr=FALSE, method="square", tl.srt=65, tl.cex=0.95, number.cex=0.8,
tl.col='black', cl.length = 5, cl.align="l", add=TRUE)
Here is the result: 结果如下:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.