【问题标题】:Saving high resolution plot in png以png格式保存高分辨率绘图
【发布时间】:2018-07-05 13:04:10
【问题描述】:

我尝试将热图保存在 png 中。

png(paste(colnames(pt2)[jj], "_heatmap.png", sep=""), width = 465, height = 225, res = 300)
heatmap.2(S5, Rowv=F,Colv=F, scale="none", trace="none", col=rg, mar=c(3.5,0,3,0),
      dendrogram = "none", key=TRUE, keysize=0.2, key.par=list(cex=0.1),
      xlab="hour of the day", ylab = "day of the week",
      density.info = "none", lmat=rbind(c(5, 4, 2), c(6, 1, 3)), 
      lhei=c(3, 4.5), lwid=c(0.1, 5, 1),
      cexRow=1, cexCol=1, margins = c(3,0))
dev.off()

但它仅适用于 res=100 最大值。我还尝试将其保存到具有 10X 高度和宽度的文件中,例如宽度 = 4650,高度 = 2250。但是我无法更改键的字体大小,它太小而且看不见。如何解决高分辨率?它显示

Error in plot.new() : figure margins too large
Error in par(op) : invalid value specified for graphical parameter "pin"

【问题讨论】:

标签: r heatmap


【解决方案1】:

您的图片尺寸太小,无法容纳边距。请注意,png 的默认单位是像素。因此,您的高度为 225 像素,分辨率为 300 dpi,生成的图像高度不到一英寸

作为一个最小的例子,这是可行的(当我们将单位指定为毫米时):

png("heatmap.png", width = 465, height = 225, units='mm', res = 300)
  plot(1:10, 1:10, mar=c(3.5,0,3,0))
dev.off()

然而,这(以像素为单位)会引发与您相同的错误

png("heatmap.png", width = 465, height = 225, res = 300)
  plot(1:10, 1:10, mar=c(3.5,0,3,0))
dev.off()

【讨论】:

    猜你喜欢
    • 2015-10-20
    • 1970-01-01
    • 2019-12-21
    • 2013-04-11
    • 1970-01-01
    • 2016-12-18
    • 2014-10-03
    • 1970-01-01
    相关资源
    最近更新 更多