我正在尝试使用 ggsave() 和 Cairo() 导出尺寸为 90x150 毫米、300 dpi 的图形。问题是,即使我在代码上正确指定了图形尺寸,它们最终还是比预期的大得多(281x468 毫米)。这是我一直在使用的代码:
x <- 1:10; y = x*x
plot = qplot(x, y, geom=c("point", "line"))
#ggsave
ggsave(plot, filename = "test.png",
width = 90, height = 150, dpi = 300, units = "mm", type = "cairo")
#Cairo
Cairo(90, 150, file="test2.png", type="png", bg="white", res = 300, units = "mm")
plot
dev.off()