这一段时间在交流群里发现好多同学讨论相关性矩阵图(correlation matrix),小编今天就给大家带来一篇相关内容的推文,包括各种相关性矩阵图类型的绘制,具体内容如下:
- R-corrplot包介绍
- R-corrplot包样例介绍
R-corrplot包介绍
R-corrplot包为R语言中专门绘制相关性矩阵的可视化工具包,其可绘制多种相关性矩阵图,corrplot包使用方便,且在可视化方法、图形布局、颜色、图例、文本标签等方面提供了丰富的绘图选项。关键还提供 p值和置信区间,以帮助用户确定相关性的统计显着性。更多关于此包的介绍可参考链接:corrplot官网[1]
R-corrplot包样例介绍
R-corrplot包提供了多个可视化样例,下面小编就依次给大家列举一下:
- 样例一
library(corrplot)
M = cor(mtcars)
corrplot(M, method = 'number') # colorful number
example01 of corrplot
- 样例二
corrplot(M, method = 'color', order = 'alphabet')
example02 of corrplot
代码语言:javascript复制corrplot(M, order = 'AOE') # after 'AOE' reorder
example03 of corrplot
- 样例三
corrplot(M, method = 'square', order = 'FPC', type = 'lower', diag = FALSE)
example04 of corrplot
代码语言:javascript复制corrplot(M, method = 'ellipse', order = 'AOE', type = 'upper')
example05 of corrplot
- 样例四
corrplot(M, method = 'square', diag = FALSE, order = 'hclust',
addrect = 3, rect.col = 'blue', rect.lwd = 3, tl.pos = 'd')
example06 of corrplot
- 样例五
corrplot(M, order = 'AOE', addCoef.col = 'black', tl.pos = 'd',
cl.pos = 'n', col = COL2('PiYG'))
example07 of corrplot
- 样例六
## add significant level stars and cluster rectangles
corrplot(M, p.mat = testRes$p, tl.pos = 'd', order = 'hclust', addrect = 2,
insig = 'label_sig', sig.level = c(0.001, 0.01, 0.05),
pch.cex = 0.9, pch.col = 'grey20')
example08 of corrplot
- 样例七
# Visualize confidence interval and cross the significant coefficients
corrplot(M, p.mat = testRes$p, lowCI = testRes$lowCI, uppCI = testRes$uppCI,
addrect = 3, rect.col = 'navy', plotC = 'rect', cl.pos = 'n')
example08 of corrplot
更多其他可视化绘制案例可参考 参考链接 网址进行查看~~
总结
今天这篇推文简单介绍R-corrplot包绘制相关性矩阵图,特别是添加显著性标注和P值的添加,希望可以帮助到大
参考资料
[1]
R-corrplot官网: https://taiyun.github.io/corrplot/。