4

我有:

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()我需要的项目一起使用。如果有人有任何建议,我将不胜感激。

4

1 回答 1

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

有关详细信息,请参阅Stack Exchange 上的?layout此答案。

于 2013-05-22T08:03:05.703 回答