试图将系数值(下角)和有效值(上角)放在一起
尝试使用corrplot.mixed,但做错了事
library(corrplot)
library(Hmisc)
mydata <- read.csv("HiBAPPaperv2_Corre.csv")
mydata.cor = cor(mydata, method = "pearson")
mydatrou= round(mydata.cor, 2)
H1517 <- cor(mydatrou)
#corrplot(H1517, method = "circle")
H1517_2 <- rcorr(as.matrix(mydata))
# Extract the correlation coefficients
H1517_2$r
# Extract p-values
H1517_2$P
## add all p-values
col1 <- colorRampPalette(c("#7F0000", "red", "#FF7F00", "yellow", "white",
"#00ff11", "#007FFF", "blue", "#00007F"))
col2 <- colorRampPalette(c("#67001F", "#B2182B", "#D6604D", "#F4A582",
"#FDDBC7", "#FFFFFF", "#D1E5F0", "#92C5DE",
"#4393C3", "#2166AC", "#053061"))
col3 <- colorRampPalette(c("red", "white", "blue"))
col4 <- colorRampPalette(c("#7F0000", "red", "#FF7F00", "yellow", "#7FFF7F",
"#00ff11", "#007FFF", "blue", "#00007F"))
whiteblack <- c("white", "black")
## using these color spectra
corrplot.mixed(H1517, upper = "square", p.mat = H1517_2$P, insig = "label_sig", addrect = 3,col = col4(10), sig.level = c(.001, .01, .05), pch.cex = 1,
lower = "number", tl.pos = "lt", tl.col = "black", tl.offset=1, tl.srt = 0)
由于以下原因而无法绘图:corrplot(corr,type =“ upper”,method = upper,diag = TRUE,tl.pos = tl.pos,错误: 形式参数“ col”与多个实际参数匹配
答案 0 :(得分:0)
如果希望上下组件使用一组颜色,则需要将lower.col
和upper.col
设置为相同的值。
使用来自?corrplot.mixed
的数据:
M <- cor(mtcars)
ord <- corrMatOrder(M, order = "AOE")
M2 <- M[ord,ord]
corrplot.mixed(M2, col=rainbow(5))
复制了您的错误。
corrplot.mixed(M2,lower.col=rainbow(5), upper.col=rainbow(5))
似乎可以正常工作(尽管我不推荐这些颜色!)