heatmap.2,顶部带有颜色键

use*_*739 2 r heatmap

我有以下代码来显示热图上方的颜色键.但是热图的顶部(稍微向右移动)的颜色键并不准确.有谁知道如何使颜色不移动?另外,如何去除热图右侧的空白区域?谢谢.

library(gplots)
heatmap.2(
  matrix(rnorm(100*10), nrow=100)
  , dendrogram='none'
  , Colv = F
  , Rowv = F
  , trace='none'
  , col = colorRampPalette(c('blue', 'yellow'))(12)
  , labRow=NA
  , labCol=NA
  , density.info='none'
  , lmat=rbind(c(4, 2), c(1, 3)), lhei=c(2, 8), lwid=c(4, 1)
)
Run Code Online (Sandbox Code Playgroud)

heatmap.2示例http://i62.tinypic.com/143grat.png

Mil*_*Tea 6

可以通过在左边的点阵中添加"填充部分"(在我的特定情况下为"5"和"6")来居中颜色键(请参阅代码最后一行的"#"注释:

heatmap.2(x=matrix(rnorm(20*10), nrow=10), Rowv=NULL,Colv=NULL, 
          col = rev(rainbow(20*10, start = 0/6, end = 4/6)), 
          scale="none",
          margins=c(3,0), # ("margin.Y", "margin.X")
          trace='none', 
          symkey=FALSE, 
          symbreaks=FALSE, 
          dendrogram='none',
          density.info='histogram', 
          denscol="black",
          keysize=1, 
          #( "bottom.margin", "left.margin", "top.margin", "left.margin" )
          key.par=list(mar=c(3.5,0,3,0)),
          # lmat -- added 2 lattice sections (5 and 6) for padding
          lmat=rbind(c(5, 4, 2), c(6, 1, 3)), lhei=c(2.5, 5), lwid=c(1, 10, 1))
Run Code Online (Sandbox Code Playgroud)

热图的中心传说.2()