9 Saving Plots

If you are starting from this page, please run the code at Libraries and Data Setup before proceeding.

To save the most recently produced plot, use ggsave(). EMF, PDF, and PNG are the most useful formats for using plots in documents.

Note that to save a plot with the EMF extension, we need to load the devEMF package and specify the extension differently.


ggplot(acs, aes(x = age)) +

ggsave("plot.emf", width = 6, height = 4, device = emf)
ggsave("plot.pdf", width = 6, height = 4)
ggsave("plot.png", width = 6, height = 4)

A full guide on saving plots with ggsave() and inserting them into documents can be found in our article Using R Plots in Documents.