Wraps ggplot2::ggsave() with pepVet's recommended defaults: auto-sizing
based on whether the plot is a multi-panel patchwork or a single panel,
300 DPI, anti-aliased PNG via ragg when available, and white background.
All arguments in ... are passed to ggplot2::ggsave() and can override
the defaults.
Usage
pepvet_save_figure(
plot,
filename = "pepvet_plot.png",
width = NULL,
height = NULL,
dpi = 300,
bg = "white",
device = NULL,
...
)Arguments
- plot
A ggplot or patchwork object produced by any pepVet plot function.
- filename
Character path for the output file. Extensions
.png,.pdf,.svg, etc. are handled byggplot2::ggsave(). Defaults to"pepvet_plot.png"in the working directory.- width, height
Finite positive numeric plot dimensions in inches. When
NULL(default), auto-sized: single-panel = 10x7, multi-panel patchwork = 14x10. Invalid values raisepepvet_error_invalid_plotbefore a graphics device is opened.- dpi
Finite positive numeric resolution in dots per inch, or one of
"screen","print", or"retina". Defaults to300. Invalid values raisepepvet_error_invalid_plotbefore a graphics device is opened.- bg
Character. Background color. Defaults to
"white".- device
Device to use. When
NULL(default) and the filename extension is.png, triesragg::agg_png()for anti-aliased output, falling back to"png". For other extensions, the device is inferred from the filename.- ...
Additional arguments passed to
ggplot2::ggsave().
Examples
if (requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("patchwork", quietly = TRUE)) {
bsa_path <- system.file("extdata", "P02769.fasta", package = "pepVet")
res <- evaluate_digest(bsa_path, enzyme = "trypsin")
p <- plot_digest_profile(res)
tmp <- tempfile(fileext = ".png")
pepvet_save_figure(p, tmp)
}
