heatmap.2,顶部带有颜色键 [英] heatmap.2 with color key on top

查看:121
本文介绍了heatmap.2,顶部带有颜色键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the following code to show the color key above the heatmap. But the color key is not exact on top (a little shifted to the right) of the heatmap. Does anyone know how to make the color not shifted? Also, how to remove the white space on the right of the heatmap? Thanks.

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)
)

推荐答案

一个人可以通过在左侧的格子中添加填充部分"(在我的情况下为"5"和"6")来使颜色键居中(在代码的最后一行看到#"注释:

One can center the color key by adding "padding sections" ("5" and "6", in my particular case) to the lattice at the left (see the "#" comment over the last line of the code:

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))

这篇关于heatmap.2,顶部带有颜色键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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