Skip to content

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Dec 17, 2024

This PR aims to fix #6243.

Briefly, missing values are thrown out and warn about when na.rm = FALSE.
The warning is skipped when na.rm = TRUE but missing values are thrown out.
When throwing out missing values, the group aesthetic is reformed so that groups with NA values break up into new uninterrupted groups.

Reprex from issue, note gradient is uniform now:

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

df <- data.frame(
  x = c(1:3, 1:3),
  ymin = c(1, 1, 1, NA, 2, 2),
  ymax = c(1.5, 2, 1.5, 2.5, 3, 2.5),
  group = c(1,1,1,2,2,2)
)

ggplot(df, aes(x, ymin = ymin, ymax = ymax, group = group, fill = x)) +
  geom_ribbon() +
  scale_fill_viridis_c()
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_ribbon()`).

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

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Quirky NA-handling of geom_ribbon()
2 participants