Skip to content

Commit 017992b

Browse files
Make geom_ribbon() draw lines separately from polygons
1 parent 047b528 commit 017992b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

R/geom-ribbon.r

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,29 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
108108
))
109109
munched <- coord_munch(coord, positions, panel_params)
110110

111-
ggname("geom_ribbon", polygonGrob(
111+
g_poly <- polygonGrob(
112112
munched$x, munched$y, id = munched$id,
113113
default.units = "native",
114114
gp = gpar(
115115
fill = alpha(aes$fill, aes$alpha),
116+
col = NA
117+
)
118+
)
119+
120+
munched_lines <- munched
121+
# increment the IDs of the lower line
122+
munched_lines$id <- munched_lines$id <- rep(c(0, max(ids, na.rm = TRUE)), each = length(ids))
123+
124+
g_lines <- polylineGrob(
125+
munched_lines$x, munched_lines$y, id = munched_lines$id,
126+
default.units = "native",
127+
gp = gpar(
116128
col = aes$colour,
117129
lwd = aes$size * .pt,
118130
lty = aes$linetype)
119-
))
131+
)
132+
133+
ggname("geom_ribbon", grobTree(g_poly, g_lines))
120134
}
121135
)
122136

0 commit comments

Comments
 (0)