ggsave2 | R Documentation |
This is a wrapper around ggplot2::ggsave()
with some ATLAS-specific
defaults. The aspect ratio is fixed to 0.618 (the golden ratio) unless the height is
manually defined. Plots are automatically spell checked and warnings are
returned if there are possible mistakes. Finally, plots saved as a pdf have
the fonts embedded using extrafont::embed_fonts()
.
ggsave2(
plot = ggplot2::last_plot(),
filename,
device = NULL,
path = NULL,
width = 7,
height = NULL,
units = "in",
dir = c("h", "v"),
dpi = "retina",
embed_fonts = FALSE,
...
)
plot |
Plot to save, defaults to last plot displayed. |
filename |
File name to create on disk. |
device |
Device to use. Can either be a device function
(e.g. png), or one of "eps", "ps", "tex" (pictex),
"pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only). If
|
path |
Path of the directory to save plot to: |
width |
Plot size in |
height |
Plot size in |
units |
Units of plot size ("in", "cm", or "mm"). Default is inches. |
dir |
Orientation of the plot. One of |
dpi |
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types. |
embed_fonts |
Logical. Use Ghostscript to embed fonts in a PDF graphic? |
... |
Additional arguments passed to |
None. Called for side effects.
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
ggsave2(p, "/mtcars.pdf", path = tempdir())
ggsave2(p, "/mtcars.png", path = tempdir())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.