Can any body suggest a function to plot heat map for upper or lower triangular matrix in R
任何人体都可以建议在R中绘制上三角矩阵或下三角矩阵的热图的函数
1 个解决方案
#1
13
The most basic way to do something like this would be using ?image
as follows:
做这样的事情最基本的方法是使用?image如下:
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.
您还可以调查函数?heatmap或在gplots包中?heatmap.2。使用gomplot2使用geom_tile执行此操作有点不同,但您可以找到一些示例来指导您完成此过程。
#1
13
The most basic way to do something like this would be using ?image
as follows:
做这样的事情最基本的方法是使用?image如下:
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.
您还可以调查函数?heatmap或在gplots包中?heatmap.2。使用gomplot2使用geom_tile执行此操作有点不同,但您可以找到一些示例来指导您完成此过程。