plot_save | R Documentation |
Exports plots based on ggplot2
in vector (PDF, SVG), raster (PNG) and R data format (Rds).
plot_save(plot, filepath, height, width, unit = "in", dpi = 600)
plot |
Plot to be exported. Needs to be based on |
filepath |
Character. The filepath for the exported plot, relative to the working directory. Do not add file extension, appropriate extension will be added to each exported file. |
height |
Numeric. The height of the exported plot in the desired length unit. |
width |
Numeric. The width of the exported plot in the desired length unit. |
unit |
Character. The unit to be used as |
dpi |
Integer. The resolution of the exported PNG image in dots per inch. Defaults to 600. |
PNG and PDF files are exported using the ggplot2
-based ggsave
function.
Exported PNG images are anti-aliased using the Cairo graphics library.
Exported SVG graphics are drawn using the R-native SVG graphics device. This is because SVG graphics exported by ggsave
are not rendered properly by the graphic design software Affinity Designer.
The downside of exporting SVG with the native graphics device is that the text is drawn as paths instead of text,
so it cannot be easily modified as text in graphic design software (e.g. set as bold, italics, etc).
Exports plot without returning a value.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.