gg_export.RdThis function is mostly a wrapper function for ggplot2::ggsave() that makes it easy to
simultaneously export a plot into pdf, svg and/or png (even multiple pngs with different dpi)
immediately open the exported files in your OS
Additionally, it offers alternatives to rendering via ggplot2::ggsave() - see arguments png_from_pdf and svg_device.
gg_export(
plot_obj = NULL,
folder_path = here::here(),
file_name = "temp",
width_cm = 16,
height_cm = 10,
pdf = "none",
png = "create",
svg = "none",
bg = "white",
png_dpi = 300,
png_fast = FALSE,
png_from_pdf = FALSE,
svg_device = "ggsave"
)Plot object to save.
Path to the destination folder (i.e. correct: "Folder/Subfolder", wrong: "Folder/Subfolder/File.png").
File name without file extension (i.e. correct: "File", wrong: "File.png").
Plot width in cm.
Plot height in cm.
Should a pdf file be created and/or immediately opened? Can be either "none", "create" or "open".
Should a png file be created and/or immediately opened? Can be either "none", "create" or "open". WARNING: is still experimental
Should a svg file be created and/or immediately opened? Can be either "none", "create" or "open".
Background colour. If NULL, uses the plot.background fill value from the plot theme.
Plot resolution of png file. Can be a vector of multiple values so that multiple png files will be created.
If TRUE, the png file is not exported via ggplot2::ggsave(..., device = "png"), but instead via ggplot2::ggsave(..., device = ragg:agg_png()), which should be faster.
If TRUE, the png file is not exported via ggplot2::ggsave(..., device = "png"), but instead converted/rendered from the pdf created via ggplot2::ggsave(device = "pdf"). This can in some cases circumvent issues where pdf and png e.g. have different font sizes.
If "svg", the svg file is not exported via ggplot2::ggsave(..., device = "svg"), but instead via grDevices::svg()/grDevices::dev.off(). This can in some cases circumvent issues with e.g. transparency.