分享

相关性矩阵绘制工具绝了!

 汉无为 2022-05-22 发布于湖北

这一段时间在交流群里发现好多同学讨论相关性矩阵图(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
corrplot(M, order = 'AOE'# after 'AOE' reorder
example03 of corrplot
  • 样例三
corrplot(M, method = 'square', order = 'FPC'type = 'lower', diag = FALSE)
example04 of corrplot
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值的添加,希望可以帮助到大家。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多