Skip to content

Conversation

mitchelloharawild
Copy link
Contributor

This PR resolves #6608:

library(ggplot2)

# Column chart
mtcars |> 
  ggplot(aes(x = factor(cyl), fill = factor(cyl))) +
  geom_col(aes(y = mpg), key_glyph = draw_key_rect)

Created on 2025-09-12 with reprex v2.1.1

As an aside, the pattern of checking if a value is NULL or NA seems to be a common one in defaulting aesthetics that could be wrapped up into a helpful infix function, e.g. x %NA0% y to use y if x is NA or empty. Looking at the code here, it seems that if both fill and colour are NA, then "grey20" may not be used?

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

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

Thank you for the PR Mitchell!
This looks good to me, can I get you to accept the snapshot change?
The change just reflects the updated logic, nothing wrong with it.

Also if you want to you can add your handle in the NEWS item.

@mitchelloharawild
Copy link
Contributor Author

Thanks, I've updated the PR.

@teunbrand teunbrand merged commit 961b194 into tidyverse:main Sep 12, 2025
12 of 13 checks passed
@teunbrand
Copy link
Collaborator

Great, thank you for the contribution!

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.

Fill colours are ignored in draw_key_rect

2 participants