Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6532.

In essence we don't want to throw a warning when e.g. colour = NULL and also nrow(data) == 0 because the length matches.
For this, we need to know data, which isn't available during the layer construction. For this reason, we move this warning during compute_geom_2() when the unmapped aesthetics are applied.

#' A data frame with layer data.
compute_geom_2 = function(self, data, params = self$aes_params, theme = NULL, ...) {
# Combine aesthetics, defaults, & params
if (empty(data)) return(data)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This prevents warning to pop up inappropriately.

@teunbrand teunbrand added this to the ggplot2 4.0.1 milestone Oct 9, 2025
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.

Ignoring empty aesthetics when data has 0 rows should be less intrusive

1 participant