So this is important to understand when experimenting and rendering in RStudio and then saving to disk. Then ggsave uses this dimension in inches with the DPI of 300 to save it to disk, creating an image of (20 * 300) x (12.5 * 300) = 6000 x 3510 dots. The plot dimension is converted in inches before saving to disk, using the screen DPI of 96 to make the conversion (1920 / 96) x (1200 / 96) = 20 x 12.5. You can see that the plot is saved with a size of 20 x 11.7 inches, which is the dimension of the screen (minus the window’s menu bar) divided by the default screen DPI of 96 as expected.īut if you check the file, you will see that the resolution is not 1920 x 1200, but 6000 x 3521 ! Ggplot(aes(bill_length_mm, bill_depth_mm, color = species)) + Then run the following code, to create a simple plot and save it to disk. Then open a new graphic device with x11() (or quartz(), or windows() depending on your system) with a dimension of 1920 x 1200. The DPI for my screen is 96, so when saving to disk, we can expect the file to be saved with a dimension of 20 x 12.5 inches.įirst load the libraries and the data library(ggplot2)
Let say your screen resolution is 1920*1200, the default device is almost taking all screen.
We’re going to make a small experiment to understand the relation between the screen resolution and the size when saving a plot.