The function png()
has arguments for defining the width and height of the graphics device, as well as an extra argument for entering the desired units of those dimensions. Check args(png)
or ?png
.
here is a reproducible example, the first part will produce a rectangular plot, while the second part will produce the default square-shaped plot.
data("mtcars")
##rectangular plot
png("p1.png", width = 640, height = 420, units = "px")
plot(mtcars$mpg, type="l", main = "p1" )
dev.off()
## default plot
png("p2.png")
plot(mtcars$mpg, type="l", main = "p2" )
dev.off()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…