save_plot: Custom plotting function to save PDF and PNG files

Description Usage Arguments Details Examples

View source: R/plotting.R

Description

Creates plots using some default settings

Usage

1
2
3
4
save_plot(x, file, dir = NULL, width = 5.25, height = 3.8,
  format = c("pdf", "png", "jpg", "all"),
  font = getOption("ggdistribute.font"), onefile = FALSE, res = 300,
  fun = NULL, ...)

Arguments

x

a plot object or list of plots

file

file name for plot. Uses name of object p as default.

dir

directory of where to save plot. Defaults to current working directory.

width

width of plot in inches

height

height of plot in inches

format

can be "pdf", "png", or "all"

font

name of font family to embed into file

onefile

print to a single pdf device or multiple

res

png pixel resolution

fun

function to use before dev.off() is called. Can print other stuff to output.

...

args passed to fun

Details

Automatically open and closes the graphics device after use.

Examples

1
2
3
4
5
6
7
8
my_plots <- list(hist(rnorm(100)), hist(rpois(100, 10)))
save_plot(my_plots, dir = "~/../Desktop", format = "all")

# embed font (extrafont package)
library(extrafont)
library(ggplot2)
custom_font_plot <- ex_plot()+theme_mejr(base_family = 'Times')
save_plot(custom_font_plot, dir = "~/../Desktop", format = "pdf", font = 'Times')

iamamutt/mejr documentation built on May 18, 2019, 1:27 a.m.