如何使用png设备向heatmap.2绘图添加更多余量? [英] How to add more margin to a heatmap.2 plot with the png device?

查看:117
本文介绍了如何使用png设备向heatmap.2绘图添加更多余量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下示例数据:

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

我使用以下代码绘制图形:

And I use this code to plot the figure:

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(5,4,4,2)+0.1))使页边距变大,但这并没有改变标签的剪切方式.

As you can see, the x-axis labels are cut off. I tried to make the margins larger with par(mar=c(7,4,4,2)+0.1) (from the default par(mar=c(5,4,4,2)+0.1)) but that does not change how the label is cut off.

我尝试更改heatmap.2中的lmatlheilwid选项,使其为:

I tried changing the lmat, lhei and lwid options in heatmap.2, so that it is:

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)如何使用heatmap.2和png设备扩大边距?

but this gives the error Error in plot.new() : outer margins too large (figure region too small) How can I enlarge the margin with heatmap.2 and the png device?

推荐答案

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

这篇关于如何使用png设备向heatmap.2绘图添加更多余量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆