Skip to contents

Takes a figure object, optionally stamps the image, and writes to a file dimensions of the figure.

Usage

write_figure(
  p_res = NULL,
  page = NULL,
  width = 3,
  height = 3,
  resolution = NULL,
  fig_file = NULL,
  fig_stamp = NULL,
  verbose = TRUE
)

Arguments

p_res

ggplot, ggforce paginated object, or ggarrange object.

page

Page number to write or NULL for a ggplot object.

width

Width in inches.

height

Height in inches.

resolution

resolution in dpi.

fig_file

File name to write the figure to.

fig_stamp

Character object containing the text to stamp on the figure with optional ===file=== placeholder.

verbose

Boolean variable when set to TRUE (default) messages will be. displayed on the terminal

Value

list with the following

  • "isgood" - Boolean variable indicating success or failure

  • "msgs" - Vector of messages

Examples

library(ggplot2)
write_figure(
 p_res = ggplot(),
 page = NULL,
 width = 3,
 height = 3,
 resolution = 200,
 fig_file = file.path(tempdir(), "write_figure_example.png"),
 fig_stamp = "stamp",
 verbose = TRUE)
#> $isgood
#> [1] TRUE
#> 
#> $msgs
#> NULL
#>