Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6616.

Briefly, whenever a (default) label is derived from a NULL aesthetic, we set the fallback = TRUE attribute. This allows labels derived from other layers to overrule that label.

Reprex from the issue, notice that we have cty and hwy labels instead of x/y labels.

devtools::load_all("~/packages/ggplot2/")

ggplot(mpg) +
  aes(cty, hwy) +
  geom_rect(
    data = data.frame(xmin = 11, xmax = 35, ymin = 17, ymax = 44),
    map = aes(
      x = NULL, y = NULL,
      xmin = xmin, xmax = xmax, 
      ymin = ymin, ymax = ymax
    )
  ) +
  geom_point()

Created on 2025-09-24 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.

setting axis aesthetics to x/y = NULL turns default axis labels into "x" / "y" instead of keeping the variable names of the next layer
1 participant