2013-05-22 38 views
4

我有:的R - gplots - 在heatmap.2卸下空格键时= FALSE

library(gplots); 
x<-matrix(seq(1:100),nrow=10,byrow=TRUE); 
heatmap.2(x, Rowv=NA, Colv=NA, scale="none", main="This title will be cut off by the white space where the non-existant key is supposed to go.", col=gray((255:0)/255), dendrogram="none",trace="none", key=FALSE); 

当键被指定为FALSE,有白色空间上图的左侧的块这会阻止完整的标题出现,与手动指定较小的页边空白相冲突,并将热图向右移动。白色空间的宽度是可控的使用"keysize=#",但是使它太小(0.8和1.0之间的某处)创建了一个错误:"Error in plot.new() : figure margins too large"

我会尝试用heatmap()代替heatmap.2()这样做,但热图无法播放以及我需要一个项目的par()。如果有人有任何建议,我会很感激。

回答

3

heatmap.2图的定位元素可以使用布局参数完成。

layout(mat = lmat, widths = lwid, heights = lhei) 

我得到一个相当可接受的热图使用以下内容。

heatmap.2(x, 
    Rowv=NA, 
    Colv=NA, 
    scale="none", 
    main="This title will be cut off by the white space where the non-existant key is supposed to go.", 
    col=gray((255:0)/255), 
    dendrogram="none", 
    trace="none", 
    key=FALSE, 
    lmat=rbind(c(2),c(3),c(1),c(4)), 
    lhei=c(1,1,9,0), 
    lwid=c(1) 
    ); 

请参考?layoutthis answer on Stack Exchange了解更多详情。

+0

我试图删除一个元素,而不是重新定位它。 Stack Exchange页面上的答案是关于向heatmap.2()函数提出的编辑,而不是在某个R脚本中修复问题的方法。 – user2407829

+0

我不认为有可能从布局中完全删除元素;重新定位似乎是要走的路。 –

+0

非常感谢。 – user2407829