Sitelet https://github.com/tidyverse/ggplot2/pull/6904
Skip to content

Fix annotate() group handling with facets - #6904

Merged
teunbrand merged 3 commits into
tidyverse:mainfrom
taekop:fix-6862-annotate-group
Oct 2, 2026
Merged

teunbrand merged 3 commits into
tidyverse:mainfrom
taekop:fix-6862-annotate-group

Conversation

@taekop

@taekop taekop commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #6862.

annotate() passed group through as a fixed layer parameter, so it never became a column of the layer data. When a facet repeats that data across panels, group no longer matches the number of rows and check_aesthetics() errors.

Following teunbrand's suggestion in the issue, group now goes into the position list with x/y so it ends up in the data and is mapped like the others. It also has to be dropped from the remaining parameters, otherwise the fixed group still overrides the mapped one. annotation_borders() passes group through annotate(), so annotation_borders(...) + facet_wrap(...) works now as well.

I haven't touched #6883 (the layout aesthetic); it looks like a separate problem, so I left it for its own fix.

@teunbrand teunbrand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this looks good to me. I simplified somewhat. Thanks for the contribution!

@teunbrand
teunbrand merged commit 013ed5f into tidyverse:main Oct 2, 2026
13 checks passed
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.

Error when combining annotation_borders() with facet_grid()

2 participants