Change width and height of ggplot2 graphic?

The size of the plot is dependent on the size of the window (in RStudio) or whatever you set it as if you are exporting it.

ggsave(g, height = ..., width = ...)

If you want to keep a constant aspect ratio...

aspect_ratio <- 2.5
height <- 7
ggsave(g, height = 7 , width = 7 * aspect_ratio)
3 Likes