Quickly arrange and label multiple figs.

fig_wrap(
  figs,
  tag = NULL,
  prefix = NULL,
  suffix = NULL,
  pos = "topleft",
  x_nudge = 0,
  y_nudge = 0,
  nrow = NULL,
  ncol = NULL,
  colour = NULL,
  alpha = NULL,
  hjust = NULL,
  vjust = NULL,
  fontsize = NULL,
  fontfamily = NULL,
  fontface = NULL,
  b_col = NULL,
  b_size = 1,
  b_pos = "offset",
  b_margin = ggplot2::margin(4, 4, 4, 4)
)

Arguments

figs

List of figs from fig().

tag

Tags to be applied to figs. Begins with first uppercase or lowercase letter supplied, or number, and continues the sequence. "A" labels them 'A', 'B', etc. "c" labels them 'c', 'd', 'e' etc.

prefix

Prefix for each tag

suffix

Suffix for each tag

pos

Position for label, to be passed to fig_tag().

x_nudge

Minor adjustments to the x position in relative plot coordindates (0 being furthest left, 1 being furthest right).

y_nudge

Minor adjustments to the y position in relative plot coordinates (0 being the bottom, 1 being the top).

nrow

Number of rows in final patchwork.

ncol

Number of cols in final patchwork.

colour

Colour for each tag

alpha

Alpha for each tag

hjust

hjust for each tag

vjust

vjust for each tag

fontsize

Fontsize for each tag

fontfamily

Fontfamily for each tag

fontface

Fontface for each tag

b_col

Colour of individual fig borders.

b_size

Size of individual fig borders (in mm).

b_pos

Either "offset" and expanding outwards from borders of figure, or "inset" and expanding inwards and partially covering the figure.

b_margin

Margins to adjust around the figs. Use ggplot2::margin()

Value

patchwork patch of supplied figs.

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)

# multiple figs
figs <- lapply(1:9, function(x) img)

# wrap the figs
fig_wrap(figs)


# Wrap the figs and auto-tag
fig_wrap(figs, tag = "A", suffix = ")")


# Wrap figs, auto-tag and adds border.
fig_wrap(figs, tag = 1, prefix = "(", suffix = ")", b_col = "black")