Once you have made your plot, you typically want to save it. This is easy with
It has saved a plot, but where? What plot was saved?
Without further speficiation, ‘ggsave’ saves the lost ggplot that was made in the R-environment. Typically, we want a little bit more control, so we tell
ggsave which ggplot-object to save:
ggplot already tells us that is saving a 7 x 5 image. This means it’s saving a 7 inch by 5 inch pdf. We can easily adjust the size:
If you meant 10 centimer instead of inch, you can either:
pdf is typically the preferred format of saving images/graphs because no matter how much you zoom in, you’ll never lose quality. This is much diffferent with png or jpeg or bmp (other extensions are available too. Nonetheless, with ggplot we can easily save to those formats as well:
In those cases, you can also specify a resolution. Compare: