将相关矩阵绘制成图形 [英] Plot correlation matrix into a graph

查看:53
本文介绍了将相关矩阵绘制成图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一些相关值的矩阵.现在我想将其绘制在一个看起来或多或少像这样的图表中:

I have a matrix with some correlation values. Now I want to plot that in a graph that looks more or less like that:

我怎样才能做到这一点?

How can I achieve that?

推荐答案

快速、肮脏且在球场上:

Quick, dirty, and in the ballpark:

library(lattice)

#Build the horizontal and vertical axis information
hor <- c("214", "215", "216", "224", "211", "212", "213", "223", "226", "225")
ver <- paste("DM1-", hor, sep="")

#Build the fake correlation matrix
nrowcol <- length(ver)
cor <- matrix(runif(nrowcol*nrowcol, min=0.4), nrow=nrowcol, ncol=nrowcol, dimnames = list(hor, ver))
for (i in 1:nrowcol) cor[i,i] = 1

#Build the plot
rgb.palette <- colorRampPalette(c("blue", "yellow"), space = "rgb")
levelplot(cor, main="stage 12-14 array correlation matrix", xlab="", ylab="", col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01))

这篇关于将相关矩阵绘制成图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆