R 题.
我有这么被迷惑width,height,dpi和unit.
为什么以下两种尺寸不同?
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,unit和dpi?
或者如何将这四个参数转换为像素单位,这对我来说更容易理解?