Skip to content

Rename with_pattern()'s group to pool and allow TRUE / FALSE - #137

Merged
trevorld merged 1 commit into
mainfrom
with_pattern-pool
Nov 12, 2026
Merged

trevorld merged 1 commit into
mainfrom
with_pattern-pool

Conversation

@trevorld

Copy link
Copy Markdown
Owner

Renames with_pattern()'s group argument to pool, and lets it be TRUE or FALSE as well as labels.

Why the rename. ggplot2 adds a group column to every layer's data. When {ggpattern} splices a whole data row with prefix = "" so that custom patterns get the plain aesthetics, as on ggpattern's master, that column always collided with our argument. The word also already means something else in grid: grid::pattern()'s group is a single logical. with_pattern() is unreleased, so this is the cheap moment to change it. After the rename, a spliced group is an ordinary pattern parameter again.

What pool accepts:

  • FALSE, the default: each area gets its own pattern.
  • TRUE: all the areas of each grob share one pattern. This is grid's group = TRUE applied per grob, e.g. one image spanning all the rectangles of a rectGrob().
  • One non-logical label per area: areas with the same label share one pattern, whether or not they touch. They must be areas of the same grob.

A logical vector of labels or an NA is an error. Per-pool parameters have one value per grob for TRUE, or one per label in the order of unique(pool).

Also:

  • patternGrob()'s default.units and draw are reserved names in with_pattern()'s dots. Before, those arguments silently consumed them whatever the prefix.
  • The factor conversion added with the dynamic dots in with_pattern() takes its pattern and parameters as dynamic dots #136 is dropped. Since R 4.0.0 data.frame() doesn't make factors by default, and ggplot2's layer data has none except PANEL.

🤖 Generated with Claude Code

…`FALSE`

ggplot2 puts a `group` column in every layer's data, so a whole data row
spliced into `with_pattern()` (as {ggpattern} needs to pass the plain
aesthetics on to custom patterns) always collided with `group`. The
word also meant both ggplot2's grouping and grid's `group` argument of
`grid::pattern()`, a single logical. `with_pattern()` is unreleased, so
the argument is now `pool`, and a spliced `group` is an ordinary pattern
parameter again (as `params$group` was on master for ggpattern).

`pool` is `FALSE` by default (each area its own pattern), `TRUE` (all
the areas of each grob share one pattern, like grid's `group = TRUE`
per grob, e.g. one image spanning a rect grob's rectangles), or one
non-logical label per area (areas with the same label share one pattern
whether or not they touch, and must be areas of the same grob). A
logical vector of labels or an `NA` is an error.

`patternGrob()`'s `default.units` and `draw` are also reserved names in
`with_pattern()`'s dots, since they were silently consumed by those
arguments whatever the `prefix`.

The factor conversion added with the dynamic dots is dropped: since R
4.0.0 `data.frame()` doesn't make factors by default and ggplot2's
layer data has none besides `PANEL`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trevorld
trevorld merged commit 7765c0e into main Nov 12, 2026
4 checks passed
@trevorld
trevorld deleted the with_pattern-pool branch November 12, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant