相关疑难解决方法(0)

R,如何准确设置ggsave的大小

R 题.

我有这么被迷惑width,height,dpiunit.

为什么以下两种尺寸不同?

ggsave(filename = "foo.png",ggplot(mtcars, aes(x=wt, y=mpg)) +
    geom_point(size=2, shape=23),width = 5, height = 4, dpi = 300, units = "in", device='png')
Run Code Online (Sandbox Code Playgroud)

ggsave(filename = "foo.png",ggplot(mtcars, aes(x=wt, y=mpg)) +
           geom_point(size=2, shape=23),width = 5, height = 4, dpi = 72, units = "in", device='png')
Run Code Online (Sandbox Code Playgroud)

我将图片的大小设置为5(英寸)*4(英寸).但是为什么当我改变时dpi,尺寸会发生变化?

如何理解之间的关系height,width,unitdpi

或者如何将这四个参数转换为像素单位,这对我来说更容易理解?

r dpi ggplot2

22
推荐指数
2
解决办法
3万
查看次数

标签 统计

dpi ×1

ggplot2 ×1

r ×1