【发布时间】:2014-07-25 13:51:38
【问题描述】:
我正在尝试将填充的轮廓图保存为 Rstudio 中的高分辨率(>600dpi)piture(png,jpeg....)。 但是,当我在 Rstudio 的界面中使用“导出”功能时,分辨率很低(图只有 20kb 左右)。
然后我尝试使用“PNG”命令来保存我的绘图,但我失败了。
请问有没有人知道如何做到这一点?
非常感谢您的帮助!
【问题讨论】:
-
请提供您用来保存绘图的命令。
我正在尝试将填充的轮廓图保存为 Rstudio 中的高分辨率(>600dpi)piture(png,jpeg....)。 但是,当我在 Rstudio 的界面中使用“导出”功能时,分辨率很低(图只有 20kb 左右)。
然后我尝试使用“PNG”命令来保存我的绘图,但我失败了。
请问有没有人知道如何做到这一点?
非常感谢您的帮助!
【问题讨论】:
我假设您希望这样做以在图像以非常大的比例渲染时保持分辨率。要使用 png(...) 函数实现这一点,您必须设置大小(height 和 width 参数)以及 ppi 中的分辨率(res 参数)。因此,下面的代码创建了一个 11 X 8.5 英寸图像、600 ppi 或 6600 X 5100 像素的 png 文件。文件大小为 435KB。
# open the png graphics device
png("volcano.png",res=600,height=8.5,width=11,units="in")
## the following is taken verbatim from the filled.contour(...) documentation
x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)
filled.contour(x, y, volcano, color=terrain.colors,
plot.title = title(main = "The Topography of Maunga Whau",
xlab = "Meters North", ylab = "Meters West"),
plot.axes = { axis(1, seq(100, 800, by = 100))
axis(2, seq(100, 600, by = 100)) },
key.title = title(main = "Height\n(meters)"),
key.axes = axis(4, seq(90, 190, by = 10))) # maybe also asp = 1
mtext(paste("filled.contour(.) from", R.version.string),
side = 1, line = 4, adj = 1, cex = .66)
##
# close the graphic device
dev.off()
如果您希望以大于 11 X 8.5 的物理尺寸进行渲染,则需要生成适当尺寸的 png。
【讨论】: