Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude labels from aes_params field #6004

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6003.

Briefly, any aesthetic in layer$computed_mapping that has an equivalent in layer$aes_params is excluded from contributing to the labels. Reprex from issue, please note the label at the colourbar is G and not <<< G >>> or g from the 1st layer.

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

d <- data.frame(x = 1, y = 2, g = 3)
d2 <- d
colnames(d2) <- c("X", "Y", "G")

attr(d[[1L]], "label") <- "<<< X >>>"
attr(d[[2L]], "label") <- "<<< Y >>>"
attr(d[[3L]], "label") <- "<<< G >>>"

ggplot() +
  geom_point(data = d, aes(x, y, colour = g), colour = "grey") + 
  geom_point(data = d2, aes(X, Y, colour = G))

Created on 2024-07-17 with reprex v2.1.1

Copy link
Member

@yutannihilation yutannihilation left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for fixing so quickly.

@teunbrand
Copy link
Collaborator Author

Thanks for the review!

@teunbrand teunbrand merged commit 7fb4c38 into tidyverse:main Jul 17, 2024
11 checks passed
@teunbrand teunbrand deleted the exclude_labels_from_aes_params branch July 17, 2024 15:55
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.

Default label is ignored when a mapping is overwritten by a parameter
2 participants