Skip to content

Commit fbf5c97

Browse files
committed
use radius in hexagon construction
1 parent 6ccb3b6 commit fbf5c97

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/geom-hex.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ GeomHex <- ggproto("GeomHex", Geom,
2828
n <- nrow(data)
2929
hexC <- hexbin::hexcoords(dx, dy, n = n)
3030

31-
hexdata <- data[rep(seq_len(n), each = 6), c("x", "y")]
32-
hexdata$x <- rep.int(hexC$x, n) + hexdata$x
33-
hexdata$y <- rep.int(hexC$y, n) + hexdata$y
31+
hexdata <- vec_rep_each(data[c("x", "y", "radius")], times = 6L)
32+
hexdata$x <- hexC$x * hexdata$radius + hexdata$x
33+
hexdata$y <- hexC$y * hexdata$radius + hexdata$y
3434

3535
coords <- coord$transform(hexdata, panel_params)
3636

0 commit comments

Comments
 (0)