Learn R Programming

lares (version 5.2.13)

export_plot: Export ggplot2, gridExtra, or any plot object into rendered file

Description

Export any ggplot2, gridExtra, or any plot object created with R into rendered png or jpg file.

Usage

export_plot(
  p,
  name = "plot",
  vars = NA,
  sep = ".vs.",
  width = 8,
  height = 6,
  format = "png",
  res = 300,
  dir = getwd(),
  subdir = NA,
  quiet = FALSE
)

Value

No return value, called for side effects.

Arguments

p

Plot object. Plot to render and export.

name

Character. File's name or suffix if vars is not NA. No need to include file format on file name.

vars

Vector. Variable names to identify by filename.

sep

Character. Separator for vars.

width, height, res

Numeric. Plot's width, height, and res (for grids).

format

Character. One of: png or jpeg.

dir, subdir

Character. In which directory/subdirectory do you wish to save the plot? Working directory as default dir.

quiet

Boolean. Display successful message with filename when saved?

See Also

Other Tools: autoline(), bind_files(), bring_api(), chr2num(), db_download(), db_upload(), export_results(), files_functions(), font_exists(), formatColoured(), formatHTML(), get_credentials(), glued(), grepm(), h2o_selectmodel(), haveInternet(), image_metadata(), importxlsx(), ip_data(), json2vector(), list_cats(), listfiles(), mail_send(), markdown2df(), move_files(), msplit(), myip(), quiet(), read.file(), statusbar(), tic(), try_require(), updateLares(), warnifnot(), what_size()

Examples

Run this code
p <- noPlot()
export_plot(p, name = "noplot", width = 10, height = 8, res = 300, dir = tempdir())
export_plot(p, name = "noplot2", subdir = "newplots", dir = tempdir())

Run the code above in your browser using DataLab