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

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

1 participant