save_plot | R Documentation |
Saves a given plot as an svg, pdf, and png file with given parameters. Recommended to use 'ggview' to settle on the appropriate width, height, and scale, then pass the parameters to this function
save_plot(
p,
filename,
rootdir = "Figures",
dpi = getOption("SOSDISS2_DPI"),
use_subfolders = TRUE,
...,
img_type = c("pdf", "png", "svg"),
.skip_save = getOption("SOSTOOLS_SKIP_PLOT_SAVE"),
postprocess
)
p |
Plot |
filename |
String, filename to use, no file extension |
rootdir |
Directory to save files to, defaults to Figures. If this does not already exist it will be created. You can set this to a subdirectory so that when you set 'use_subfolders' to TRUE it will create the correct subfolders where you want them. |
dpi |
integer, dpi to use for png file. Default uses option SOSDISS2_DPI, which is set to 300 on load. |
use_subfolders |
Logical, defaults to FALSE, if TRUE will create pdf, png, and svg subfolders in the Figures/ directory and save each figure to the appropriate subdirectory. Useful when you have a LOT of figures. |
... |
Additional names parameters to pass |
img_type |
character vector of image file types to save. Defaults to c("pdf", "png", "svg"). Usually used to save only png files of diagnostic plots that dont need vector versions. |
.skip_save |
Logical, whether to skip saving the plot. Useful if you're rerunning a script or rmd/qmd doc and don't want to re-save plots. You can also use 'option(SOSTOOLS_SKIP_PLOT_SAVE = FALSE)' to set this globally for the current session. |
postprocess |
A named list of functions to apply to the specific output files AFTER they are saved. Eg for watermarking or cropping purposes. The names must correspond to the individual filetypes, all of which must also be specified in 'img_type' |
Default behavrior is to create a 'Figures/' directory in the current working directory.
Invisibly returns the paths to the saved plots
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.