Unified function to save ggplot objects in one or more formats.
save_ipeaplot(
gplot = ggplot2::last_plot(),
file.name,
format = NULL,
width = 6.3,
height = 3.94,
units = c("in", "mm", "cm", "px"),
dpi = 300,
background = "white",
quality = 95,
path = ".",
scale = 1,
overwrite = TRUE,
include_date = FALSE,
date_format = "%Y%m%d",
use_cairo = TRUE,
use_ragg = TRUE,
quiet = TRUE,
...
)Named (invisible) vector with the paths of the saved files.
ggplot object. Default: ggplot2::last_plot().
Base name of the file (without extension). E.g., "results/figs/my_plot".
Vector with one or more of: "eps", "jpg", "pdf", "png", "svg". If NULL, uses getOption("ipea.plot.default_format", "eps").
Plot dimensions (default 160 x 100).
Units: "mm", "cm", "in", "px" (default "in").
DPI for raster formats (default 300).
Background color; use NA for transparent PNGs. For JPEG (no transparency), NA becomes "white".
JPEG quality (0 to 100) (default 95).
Output directory (default ".").
Scale factor passed to ggsave (default 1).
If FALSE, does not overwrite existing files: creates suffixes _1, _2, ... (default TRUE).
If TRUE, appends the date to the file name: _YYYYMMDD (default FALSE).
Date format (default "%Y%m%d").
Prefer using Cairo for PDF/EPS (default TRUE).
Prefer using ragg for PNG/JPG when available (default TRUE).
Suppress messages from ggsave when supported (default TRUE).
Passed to ggplot2::ggsave() (and therefore to the underlying graphics devices when applicable).