更改corrplot.mixed中的文本颜色

更改corrplot.mixed中的文本颜色,r,r-corrplot,R,R Corrplot,在r软件包corrplot中,您可以混合相关矩阵下半部分和上半部分的图形类型,以形成良好的视觉效果。我希望在我的矩阵的下半部分有数字,在矩阵的上半部分有省略号,这很好。但是,根据我的数据,我看不到一些相关数字,因为它们接近于0。下面是我正在使用的代码和当前输出 是否有办法更改矩阵下半部分的文本颜色?我想将相关系数的颜色更改为非白色(它们不需要从红色变为蓝色,黑色就可以了) #保存相关矩阵以获得再现性 #根据以下答案修改了矩阵:http://stackoverflow.com/a/36893890

r
软件包
corrplot
中,您可以混合相关矩阵下半部分和上半部分的图形类型,以形成良好的视觉效果。我希望在我的矩阵的下半部分有数字,在矩阵的上半部分有省略号,这很好。但是,根据我的数据,我看不到一些相关数字,因为它们接近于0。下面是我正在使用的代码和当前输出

是否有办法更改矩阵下半部分的文本颜色?我想将相关系数的颜色更改为非白色(它们不需要从红色变为蓝色,黑色就可以了)

#保存相关矩阵以获得再现性
#根据以下答案修改了矩阵:http://stackoverflow.com/a/36893890/5623577

cormatx他们在
?corrplot
中有一个例子(在“圆圈+黑数”下)。看起来您必须调用
corrplot
两次:一次是先绘制椭圆(颜色),然后再分别绘制系数(例如指定color=black),因为如果在
corrplot.mixed
中指定
col=“black”
,椭圆也将是黑色的

另外,如果您查看
corrplot.mixed
代码,您可以看到它将相同的
..
传递给上下调用,这就是为什么在
corrplot.mixed
中指定例如
color=“black”
将同时绘制省略号和文本黑色,而不仅仅是文本

#绘制椭圆+装饰
corrplot(cormatx,type=“upper”,method=“eliple”,
tl.pos=“lt”,tl.col=“黑色”,tl.offset=1,tl.srt=0)
#以黑色绘制标签(禁用所有其他已绘制的内容)
corrplot(cormatx,add=T,type=“lower”,method=“number”,
col=“黑色”,diag=F,tl.pos=“n”,cl.pos=“n”)
#如果您不喜欢对角线上的线条(即corrplot.mixed的diag=“n”),
#查看corrplot.mixed会生成以下代码:

n从
corrplot
0.84版开始,现在可以有不同颜色的文本和省略号。比如说,

corrplot.mixed(MyMatrix,lower.col=“black”,number.cex=.7)


指定矩阵下半部分中的文本为黑色。

corrplot.mixed是否可以包含用于打印的调色板?
#Saves the correlation matrix for reproducibility
#The matrix was modified based on the answer here: http://stackoverflow.com/a/36893890/5623577
cormatx <- structure(c(1, 0.480473436029381, 0.727971392165508, 0.0755790813842022, 
0.647226624978262, 0.706156814758194, 0.73971915882987, 0.073024457099958, 
0.480473436029381, 1, 0.540515552878261, 0.106196818240067, 0.505171500429873, 
0.480694458288349, 0.538693541543583, 0.158300667842954, 0.727971392165508, 
0.540515552878261, 1, 0.111168537597397, 0.587432598932939, 0.673406541830384, 
0.724533755640279, 0.139232852746538, 0.0755790813842022, 0.106196818240067, 
0.111168537597397, 1, -0.0844917222701804, 0.0382605955575862, 
-0.00462812019681349, 0.000406894700952559, 0.647226624978262, 
0.505171500429873, 0.587432598932939, -0.0844917222701804, 1, 
0.668544141384562, 0.761303240927891, 0.152127182963817, 0.706156814758194, 
0.480694458288349, 0.673406541830384, 0.0382605955575862, 0.668544141384562, 
1, 0.772678948045676, 0.119611111043454, 0.73971915882987, 0.538693541543583, 
0.724533755640279, -0.00462812019681349, 0.761303240927891, 0.772678948045676, 
1, 0.174453831824302, 0.073024457099958, 0.158300667842954, 0.139232852746538, 
0.000406894700952559, 0.152127182963817, 0.119611111043454, 0.174453831824302, 
1), .Dim = c(8L, 8L), .Dimnames = list(c("A. SAT Critical Reading", 
"B. SAT Mathematics", "C. SAT Writing Multiple Choice", "D. SAT Essay", 
"E. TOEFL Listening Comprehension", "F. TOEFL Structure and Written Expression", 
"G. TOEFL Reading Comprehension", "H. TOEFL Test of Written English"
), c("A", "B", "C", "D", "E", "F", "G", "H")))

#Creates the corrplot
corrplot.mixed(cormatx, upper = "ellipse", lower = "number",
               tl.pos = "lt", tl.col = "black", tl.offset=1, tl.srt = 0)
# draw ellipses + decorations
corrplot(cormatx, type="upper", method="ellipse",
         tl.pos="lt", tl.col="black",  tl.offset=1, tl.srt=0)
# draw labels in black (disabling all the other stuff already drawn)
corrplot(cormatx, add=T, type="lower", method="number",
         col="black", diag=F, tl.pos="n", cl.pos="n")
# if you don't like the lines on the diagonal, (ie diag="n" of corrplot.mixed),
#  having a look at corrplot.mixed yields the following code:
n <- nrow(cormatx)
symbols(1:n, n:1, add=TRUE, bg="white", fg="grey", inches=F, squares=rep(1, n))