save_plot: Simple wrapper to ggsave

Description Usage Arguments Examples

Description

Wrapper to ggsave to auto-save the annoying fiddly arguments I always forget. Works only w/ ggplot2 objects.

Usage

1
2
save_plot(filename, plot = last_plot(), saveBoth = FALSE, width = NA,
  height = NA, units = "in", scale = 1)

Arguments

filename

string containing file name

plot

which plot to save; by default, the last one created

saveBoth

If TRUE, save both a .pdf and .png

width

width of rendered plot

height

height of the rendered plot

units

units of the width/height of rendered plot (typically inches – 'in')

scale

scalar factor to enlarge/shrink the rendered plot

Examples

1
2
3
4
5
6
7
# create a figure
p = ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point()
p + stat_summary(geom = 'point', fun.y = 'mean', colour = 'red', size = 5, shape = 21, fill = NA)

# save figures
save_plot('last_plot.pdf', width = 5, height = 5)
save_plot('plot_p.pdf', plot = p, width = 5, height = 5)

flaneuse/llamar documentation built on May 16, 2019, 1:18 p.m.