gpt4 book ai didi

r - 如何使用 png 设备为 heatmap.2 绘图添加更多边距?

转载 作者:行者123 更新时间:2023-12-04 03:11:46 26 4
gpt4 key购买 nike

我有以下示例数据:

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

这给了我这个热图:

enter image description here

如您所见,x 轴标签被切断。我试图用 par(mar=c(7,4,4,2)+0.1) 使边距更大(来自默认 par(mar=c(5,4,4,2)+0.1) )但这不会改变标签的切断方式。

我尝试更改 lmat , lheilwid heatmap.2 中的选项,因此它是:
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 设备放大边距?

最佳答案

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

enter image description here

关于r - 如何使用 png 设备为 heatmap.2 绘图添加更多边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21427863/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com