簡體   English   中英

如何使用png設備為heatmap.2繪圖添加更多邊距?

[英]How to add more margin to a heatmap.2 plot with the png device?

我有以下示例數據:

sel = structure(c(1.29955, 2.52295, 1.11021, 2.52008, 8.20255, 8.50118, 
                  5.82189, 5.8108, 1.55928, 8.2552, 5.25119, 5.55055, 1.22525, 
                  3.152, 3.9299, 5.50921, 5.25591, 5.11218, 1.55951, 2.5525, 
                  9.2358, 2.0928, 5.2538, 2.5539, 8.52592, 2.59521, 5.55858, 
                  5.92955, 2.22089, 1.52105), 
         .Dim = c(10L, 3L), .Dimnames = list(c("a", "b", 
         "c", "d", "e", "f", "g", "h", 
         "i", "j"), c("Label.1", "Label.2", "Label.3")))

我使用此代碼繪制圖形:

col = c("#FF0000", "#FF0000", "#FF0000")
par(mar=c(7,4,4,2)+0.1) 
png(filename='test.png', width=800, height=750)
heatmap.2(sel, col=redgreen(75), scale="row", ColSideColors=col,
          key=TRUE, symkey=FALSE, density.info="none", trace="none")
graphics.off()

這給了我這個熱圖:

在此輸入圖像描述

如您所見,x軸標簽被切斷。 我試圖用par(mar=c(7,4,4,2)+0.1)來增加邊距par(mar=c(7,4,4,2)+0.1) (從默認的par(mar=c(5,4,4,2)+0.1) )但這樣做不要改變標簽被切斷的方式。

我嘗試在lhei更改lmatlheilwid選項,因此它是:

heatmap.2(zebrafishSel, col=redgreen(75), scale="row", ColSideColors=zebracolors,
          key=TRUE, symkey=FALSE, density.info="none", trace="none", 
          lmat=rbind(c(2),c(3),c(1),c(4)), 
          lhei=c(1,1,9,0), 
          lwid=c(1))

但這會給出Error in plot.new() : outer margins too large (figure region too small)的錯誤Error in plot.new() : outer margins too large (figure region too small)如何使用heatmap.2和png設備擴大邊距?

col = c("#FF0000", "#FF0000", "#FF0000")
par(mar=c(7,4,4,2)+0.1) 
png(filename='test.png', width=800, height=750)
heatmap.2(sel, col=redgreen(75), scale="row", ColSideColors=col,
                     key=TRUE, symkey=FALSE, density.info="none",cexRow=1,cexCol=1,margins=c(12,8),trace="none",srtCol=45)
graphics.off()

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM