One save helper for every figure so resolution, device and font rules live
in one place. PNG uses ragg::agg_png (sharp text, true 600 dpi, reliable
transparency and font rendering); PDF uses grDevices::cairo_pdf (vector
output that embeds Inter — base pdf() would not). The bundled Inter font is
registered first so exported text matches the screen.
Usage
zhn_save_plot(
plot,
file,
format = c("png", "pdf"),
width = 8,
height = 5,
transparent = FALSE
)Arguments
- plot
A ggplot2::ggplot (or other printable plot) object.
- file
Output path; written as-is.
- format
One of
"png"or"pdf".- width, height
Dimensions in inches.
- transparent
Logical; transparent background if
TRUE, else white.