Skip to content

Conversation

@teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Oct 8, 2025

This PR aims to fix #6680.

The issue was caused by single groups that don't get assigned an align_padding computed aesthetic, because of the early exit here:

ggplot2/R/stat-align.R

Lines 19 to 21 in 081806c

if (is_unique(data$group)) {
return(data)
}

These would get NA values for align_padding when combined with other panels, which this PR now keeps around.

Reprex from issue:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

df <- data.frame(
  x = c(1, 2, 1, 2, 1, 2),
  y = c(1, 1, 1, 1, 1, 1),
  g = c("A", "A", "B", "B", "C", "C"),
  f = c("x", "x", "x", "x", "y", "y")
)

ggplot(df, aes(x, y, fill = g)) +
  geom_area(position = "stack") +
  facet_wrap(vars(f))

Created on 2025-10-08 with reprex v2.1.1

@teunbrand teunbrand added this to the ggplot2 4.0.1 milestone Oct 20, 2025
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@teunbrand teunbrand merged commit 5663e3d into tidyverse:main Oct 27, 2025
13 checks passed
@teunbrand teunbrand deleted the fix_6680 branch October 27, 2025 14:46
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.

Version 4.0.0 issue with facet_grid & facet_wrap randomly drops levels from fill aes

2 participants