patchwork_design: Create a patchwork design specification

View source: R/patchwork_design.R

patchwork_designR Documentation

Create a patchwork design specification

Description

Create a non-overlapping patchwork design layout by specifying a list of block dimensions.

Motivation: When using the "design" argument of patchwork::plot_layout(), it can be cumbersome to use the syntax required by the patchwork framework. This syntax requires creating a vector of area elements, each of which is created by a call to patchwork::area(). This area function requires specifying the left/right/top/bottom coordinates of each block. This can become impractical when designing and making multiple edits to a complex layout in which we want our patches to be tiled/adjacent to one another. It can be much easier to instead specify a list of block dimensions, and have a function dynamically calculate all the necessary top/left/bottom/right coordinates. That is what this function does.

Usage

patchwork_design(..., margin.row = 0)

Arguments

...

Character vectors specifying block dimensions. Each vector corresponds to a row in the output layout.

Each element of each vector is a character of the form "WxH", (e.g. "8x10"). The height of each row will be set to the height of the tallest block in the row. Blocks with extra vertical space will be vertically centered. The width of each row will be set to the width of the widest row, and any extra horizontal space will be evenly distributed in between blocks in the row.

margin.row

An optional integer specifying the number of units of space to place in-between rows.

Value

A vector of patchwork areas.

See Also

patchwork::area(), patchwork::plot_layout()

Examples

# Create a layout with 2 blocks in the first row,
# 2 blocks in the second row, 1 block in the
# third row, and 2 blocks in the fourth row.

patchwork_design(
  c("8x10", "6.5x18"),
  c("9x12", "10x17"),
  c("4x28"),
  c("11x9", "11x13"),
  margin.row = 2
)

adamleejohnson/R-ajtools documentation built on April 4, 2022, 7:24 a.m.