Save the plot into multiple formats
Usage
save_plot(
plot,
prefix,
devpars = NULL,
bg = "white",
formats = c("png", "pdf"),
selfcontained = TRUE
)Arguments
- plot
The plot object. Can be a ggplot2 object or a plotly/htmlwidget object. For plotly/htmlwidget objects, only
"html"format is supported. If static formats are requested, a warning is issued and an HTML file is saved instead. For ggplot2 objects,"html"is also supported by converting the plot to a plotly object viaplotly::ggplotlyfirst.- prefix
The prefix of the file The ending
.is removed from the prefix. So both/path/to/fileand/path/to/file.are valid and will save the files as/path/to/file.png,/path/to/file.pdfand/path/to/file.<format>etc.- devpars
The device parameters
resis the resolution in pixels per inch (PPI) for raster formats (e.g. PNG). Default is 100.widthandheightcan be specified as absolute values (e.g. 800) or relative values (e.g. "+100", "-50", "x2", "/2") to the default size of the plot.
- bg
The background color
- formats
The formats to save. Use
"html"to save as an interactive HTML file.- selfcontained
Whether to save the HTML file as a self-contained file (only used when saving as HTML). Default is
TRUE.