gpt4 book ai didi

r - heatmap.2 顶部有颜色键

转载 作者:行者123 更新时间:2023-12-02 07:28:41 24 4
gpt4 key购买 nike

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

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

heatmap.2 example

最佳答案

可以通过在左侧的格子中添加“填充部分”(在我的特定情况下为“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))

centered legend of heatmap.2()

关于r - heatmap.2 顶部有颜色键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24621070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com