Skip to content

Commit c9dd961

Browse files
authored
fix problems during ribbon data sort (#3235)
1 parent 552707f commit c9dd961

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

R/geom-ribbon.r

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
6363
required_aes = c("x", "ymin", "ymax"),
6464

6565
setup_data = function(data, params) {
66-
transform(data[order(data$PANEL, data$group, data$x), ], y = ymin)
66+
if (is.null(data$ymin) && is.null(data$ymax)) {
67+
stop("Either ymin or ymax must be given as an aesthetic.", call. = FALSE)
68+
}
69+
data <- data[order(data$PANEL, data$group, data$x), , drop = FALSE]
70+
data$y <- data$ymin %||% data$ymax
71+
data
6772
},
6873

6974
draw_key = draw_key_polygon,

0 commit comments

Comments
 (0)