2013-05-22 39 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