Skip to content
Back to skills

Patchwork

ASecurity

R patchwork package for combining ggplot2 plots. Use for arranging multiple plots into composite figures.

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 5, 2026
data

Security analysis

A100/100

Scanned June 5, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill patchwork --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Patchwork?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Patchwork
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-patchwork/badge)](https://www.skillsdirectory.com/skills/leolin990405-patchwork)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: patchwork
description: R patchwork package for combining ggplot2 plots. Use for arranging multiple plots into composite figures.
---

# patchwork

Combine ggplot2 plots.

## Basic Composition

```r
library(patchwork)

# Side by side
p1 + p2

# Stacked
p1 / p2

# Complex layouts
(p1 | p2) / p3
(p1 + p2) / (p3 + p4)
p1 | (p2 / p3)
```

## Layout Control

```r
# Specify layout
p1 + p2 + p3 + plot_layout(ncol = 2)
p1 + p2 + p3 + plot_layout(nrow = 1)

# Widths and heights
p1 + p2 + plot_layout(widths = c(2, 1))
p1 / p2 + plot_layout(heights = c(1, 2))

# Design layout
design <- "
  AAB
  AAC
  DEC
"
p1 + p2 + p3 + p4 + p5 + plot_layout(design = design)

# Area function
design <- c(
  area(1, 1, 2, 2),
  area(1, 3),
  area(2, 3),
  area(3, 1, 3, 3)
)
p1 + p2 + p3 + p4 + plot_layout(design = design)
```

## Annotations

```r
# Add title to composition
p1 + p2 + plot_annotation(
  title = "Combined Plot",
  subtitle = "Subtitle",
  caption = "Source: Data",
  tag_levels = "A"
)

# Tag levels
p1 + p2 + plot_annotation(tag_levels = "A")  # A, B, C
p1 + p2 + plot_annotation(tag_levels = "1")  # 1, 2, 3
p1 + p2 + plot_annotation(tag_levels = "i")  # i, ii, iii
p1 + p2 + plot_annotation(tag_levels = c("A", "1"))  # Nested

# Tag styling
p1 + p2 + plot_annotation(
  tag_levels = "A",
  tag_prefix = "Fig. ",
  tag_suffix = ")"
)
```

## Spacers and Guides

```r
# Add empty space
p1 + plot_spacer() + p2

# Collect guides
p1 + p2 + plot_layout(guides = "collect")

# Collect and position
p1 + p2 + plot_layout(guides = "collect") &
  theme(legend.position = "bottom")
```

## Modifying All Plots

```r
# Apply theme to all
(p1 + p2 + p3) & theme_minimal()

# Apply scale to all
(p1 + p2 + p3) & scale_color_viridis_d()

# Modify specific plots
p1 + p2 + p3 & theme(legend.position = "none")
```

## Insets

```r
# Add inset plot
p1 + inset_element(
  p2,
  left = 0.6, right = 0.95,
  bottom = 0.6, top = 0.95
)

# Align inset
p1 + inset_element(p2, 0.6, 0.6, 1, 1, align_to = "panel")
```

## Wrap Plots

```r
# Wrap non-ggplot objects
wrap_elements(grid::textGrob("Text"))
wrap_elements(~plot(1:10))

# Wrap ggplot
wrap_plots(list(p1, p2, p3), ncol = 2)
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.