Function that generates a figure and saves it as a JPEG file using common settings.

save_jpeg(
  file_name,
  fun_plot,
  dmn = c(5, 5),
  units = "in",
  res = 300,
  quality = 90,
  pointsize = 12,
  bg = "white",
  family = "",
  type = c("windows", "cairo"),
  symbolfamily = "default",
  return_file_name = FALSE,
  ...
)

save_jpg(
  file_name,
  fun_plot,
  dmn = c(5, 5),
  units = "in",
  res = 300,
  quality = 90,
  pointsize = 12,
  bg = "white",
  family = "",
  type = c("windows", "cairo"),
  symbolfamily = "default",
  return_file_name = FALSE,
  ...
)

Arguments

file_name

A character string, the desired path to the PNG file.

fun_plot

A function that generates a figure as output.

dmn

A numeric vector of two values, the width and height of the figure to save (default is in inches).

units

A character string, the units for figure dimensions (see grDevices::jpeg).

res

An integer value, the figure resolution (see grDevices::jpeg).

quality

A numeric value from 0 100, a percentage governing compression (lower values give more compression but worse quality; see grDevices::jpeg).

pointsize

An integer value, the point size of text (see grDevices::jpeg).

bg

a character string, the background color (see grDevices::jpeg).

family

A character string specifying the font family (see grDevices::jpeg).

type

A character string governing how plotting is done (see grDevices::jpeg).

symbolfamily

A character string for cairographics options (see grDevices::jpeg).

return_file_name

A logical value, if TRUE returns the file name as a character string.

...

Additional arguments for the fun_plot function.

Value

A JEPG file, and optionally the file name.