View source: R/save_functions.R
save_plot | R Documentation |
Saves a ggplot2 plot to a file in PNG, PDF, or JPG format.
save_plot(
plot,
filename = "plot",
format = c("png", "pdf", "jpg"),
width = 8,
height = 6,
dpi = 300
)
plot |
A ggplot2 object. |
filename |
Name of the file to save, with or without extension. |
format |
Output format. One of "png", "pdf", or "jpg". |
width |
Width of the saved plot in inches. |
height |
Height of the saved plot in inches. |
dpi |
Resolution of the plot in dots per inch (default is 300). |
Saves the file to a temporary directory (if no path is given).
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
save_plot(p, filename = file.path(tempdir(), "scatterplot"), format = "png")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.