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

Regression: NA values not being handled correctly in GeomRibbon #1549

MikeWise2718 opened this Issue Feb 17, 2016 · 2 comments


None yet
2 participants

MikeWise2718 commented Feb 17, 2016

There seems to be a missing handle_na function in GeomRibbon. I answered a question with a workaround here:


This comment has been minimized.


hadley commented Feb 17, 2016

Can you please include a minimal reproducible example inline?


This comment has been minimized.

MikeWise2718 commented Feb 17, 2016

Sure. The following program should have a gap at x==4, (where there is an NA in the data). But it does not.

However it does if I create a new GeomRibbon identical to the first but with a handle_na default function doing nothing.



test <- data.frame(x = rep(1:10, 3), y = abs(rnorm(30)), z = rep(LETTERS[1:3], 10)) %>% arrange(x, z)

test[test$x == 4, "y"] <- NA

test$ymax <- test$y
test$ymin <- 0
zl <- levels(test$z)
for (i in 2:length(zl)) {
zi <- test$z == zl[i]
zi_1 <- test$z == zl[i - 1]
test$ymin[zi] <- test$ymax[zi_1]
test$ymax[zi] <- test$ymin[zi] + test$ymax[zi]

ggplot(test, aes(x = x, y = y, ymax = ymax, ymin = ymin, fill = z)) +
geom_ribbon() +
scale_x_continuous(breaks = 1:10)

@hadley hadley reopened this Feb 18, 2016

@hadley hadley closed this in a760ff6 Feb 18, 2016

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.