as_figure: Convert an ggplot into a figure object.

View source: R/coercion.R

as_figureR Documentation

Convert an ggplot into a figure object.

Description

Bundles a ggplot/cowplot graphic, file reference, the final rendered graphic dimensions and markdown references in one figure object.

Usage

as_figure(x, ...)

## S3 method for class 'ggplot'
as_figure(
  x,
  label,
  w,
  h,
  unit = c("mm", "cm", "in"),
  ref_name = NULL,
  caption = NULL,
  legend_text = NULL,
  ...
)

Arguments

x

a ggplot/cowplot object

...

extra arguments, currently none.

label

the final file name

w

the final width after saving/rendering

h

the final height after saving/rendering

unit

the unit of h and w, mm be default

ref_name

optional, name of the reference to the figure, used mainly in markdown documents.

caption

optional, text to be presented in the figure caption.

legend_text

optional, text to be presented in the extended figure legend.

Details

ref_name: needs to be a valid markdown/bookdown reference name. By default, spaces, slashes and underscores are silently turned into '-'.

Value

An object of class figure.


PiotrTymoszuk/figur documentation built on July 16, 2024, 1:15 a.m.