为上或下三角矩阵绘制热图 [英] Plotting a heat map for an upper or lower triangular matrix
本文介绍了为上或下三角矩阵绘制热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何主体都可以提供一个函数来绘制上下三角形矩阵的热图,这个函数在R中是最基本的方法。做这样的事情会使用?image
如下:
M < - 矩阵(runif(100),10,10)
M [lower.tri(M)] < - NA
image(1:10,1:10,M)
会导致类似这样的结果:
您也可以调查函数?heatmap
或在 gplots
包中?heatmap.2
。这样做使用 ggplot2
使用 geom_tile
有点不同,但您可以找到一些示例来指导您完成 here 。
Can any body suggest a function to plot heat map for upper or lower triangular matrix in R
解决方案
The most basic way to do something like this would be using ?image
as follows:
M <- matrix(runif(100),10,10)
M[lower.tri(M)] <- NA
image(1:10,1:10,M)
which would result in something like this:
You could also investigate the functions ?heatmap
or in the gplots
package ?heatmap.2
. Doing this using ggplot2
using geom_tile
is a little different but you can find some examples to walk you through the process here.
这篇关于为上或下三角矩阵绘制热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文