Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 (development version)

* Fixed a regression in `geom_hex()` where aesthetics were replicated across
bins (@thomasp85, #5037 and #5044)

# ggplot2 3.4.0
This is a minor release focusing on tightening up the internals and ironing out
some inconsistencies in the API. The biggest change is the addition of the
Expand Down
16 changes: 8 additions & 8 deletions R/geom-hex.r
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ GeomHex <- ggproto("GeomHex", Geom,

n <- nrow(data)

data <- data[rep(seq_len(n), each = 6), ]
data$x <- rep.int(hexC$x, n) + data$x
data$y <- rep.int(hexC$y, n) + data$y
hexdata <- data[rep(seq_len(n), each = 6), c("x", "y")]
hexdata$x <- rep.int(hexC$x, n) + hexdata$x
hexdata$y <- rep.int(hexC$y, n) + hexdata$y

coords <- coord$transform(data, panel_params)
coords <- coord$transform(hexdata, panel_params)

ggname("geom_hex", polygonGrob(
coords$x, coords$y,
gp = gpar(
col = coords$colour,
fill = alpha(coords$fill, coords$alpha),
lwd = coords$linewidth * .pt,
lty = coords$linetype,
col = data$colour,
fill = alpha(data$fill, data$alpha),
lwd = data$linewidth * .pt,
lty = data$linetype,
lineend = lineend,
linejoin = linejoin,
linemitre = linemitre
Expand Down
Loading