A wrapper for calling grDevices::png()
then grDevices::dev.off()
. Allows
users to save a plot to a specified path. The preferred method for
ggplot2::ggplot
objects remains ggplot::ggsave()
. However if you wish to
use this function to save ggplot2::ggplot
objects, print the plot as the
last step of plot_code
.
save_png(plot_code, path, width = 8, height = 6, units = "in", res = 600, ...)
code required to generate the plot, sandwiched in curly braces.
character(1)
specifying path for where to save your plot,
including file name.
the width of the device.
the height of the device.
The units in which height
and width
are
given. Can be px
(pixels, the default), in
(inches),
cm
or mm
.
The nominal resolution in ppi which will be recorded in the
bitmap file, if a positive integer. Also used for units
other than the default, and to convert points to pixels.
additional arguments are passed to grDevices::png()
.
Invisibly, the path to saved plot.