Skip to content

Commit aa29fc2

Browse files
committed
annotation_map: get group id from munched data (Fixes #568)
1 parent c97be66 commit aa29fc2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

R/annotation-map.r

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ GeomAnnotationMap <- proto(GeomMap, {
4141
objname <- "map"
4242

4343
draw_groups <- function(., data, scales, coordinates, map, ...) {
44+
# Munch, then set up id variable for polygonGrob -
45+
# must be sequential integers
4446
coords <- coord_munch(coordinates, map, scales)
45-
id <- match(map$group, unique(map$group))
46-
47-
polygonGrob(coords$x, coords$y, default.units = "native", id = id,
47+
coords$group <- coords$group %||% coords$id
48+
grob_id <- match(coords$group, unique(coords$group))
49+
50+
polygonGrob(coords$x, coords$y, default.units = "native",
51+
id = grob_id,
4852
gp = gpar(
4953
col = data$colour, fill = alpha(data$fill, data$alpha),
5054
lwd = data$size * .pt))

0 commit comments

Comments
 (0)