cp_plotSave: Saving Plots at Prespecified Size and Resolution

Description Usage Arguments Value Examples

View source: R/cp_plotSave.R

Description

This function is a wrapper around ggsave() that uses pre-specified values which correspond to the possible graphics sizes in my lecture and presentation slides.

Usage

1
cp_plotSave(filename, plot, device = "png", preset = c("sm", "med", "lg"), dpi = 300)

Arguments

filename

File name to create on disk; must be quoted

plot

Plot to save, defaults to last plot displayed if no plot included

device

Device to use. Can be 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).

preset

Preset size ("sm", "med", "lg")

dpi

Dots per inch for plot

Value

Saves a file to the disk in the pre-determined size. preset = "sm"

Examples

1
2
3
4
5
6
7
8
## Not run: 
p <- ggplot(mpg, aes(hwy)) + geom_histogram()

cp_plotSave("hwy.png", preset = "sm")
cp_plotSave("hwy.png", p, preset = "med")
cp_plotSave("hwy.png", p, preset = "lg")

## End(Not run)

chris-prener/prener documentation built on May 17, 2019, 9:12 a.m.