fig: Parse Image to a Fig

View source: R/fig.R

figR Documentation

Parse Image to a Fig

Description

Read image and convert to ggplot object, for use with other ggplot objects when assembling with the {patchwork} package. Can also specify a border.

Usage

fig(
  path,
  aspect.ratio = "default",
  link_dim = TRUE,
  b_col = NULL,
  b_size = 1,
  b_pos = "offset",
  b_margin = ggplot2::margin(4, 4, 4, 4)
)

Arguments

path

Path to image file.

aspect.ratio

Manually override the image's aspect ratio or set "free" to allow fig to be resized by patchwork.

link_dim

Logical, whether to lock the dimensions & aspect.ratio of the aligned plots to that of this fig.

b_col

Colour of the border line.

b_size

Size of the border line.

b_pos

Whether the border is 'offset' (expands out from figure) or 'inset' and expands inwards, partially covering up the figure.

b_margin

Margin around the fig. Use ggplot2::margin()

Value

{ggplot2} object

Examples


library(figpatch)
library(ggplot2)

# Attach the fig image file
image <- system.file("extdata", "fig.png", package = "figpatch", mustWork = TRUE)

# Read in the image as a 'fig'
img <- fig(image)

img

figpatch documentation built on May 3, 2022, 9:07 a.m.