Skip to content

stat_binhex, stat_summary_hex, and ggplot2's bins are out of kilter #1383

Closed
@AmagicalFishy

Description

@AmagicalFishy
library(ggplot2)
dat <- data.frame(x = rnorm(100000, 0, 5), y = rnorm(100000, 0, 5), z = rnorm(100000, 42, 42))

hexHist = ggplot(dat, aes(x, y, z = z)) + 
    stat_binhex(bins = 10) +
    stat_summary_hex(aes(label=..value..), bins = 10,
                     fun = function(z) {
                         (round(sum(z)/length(z), 0))
                     },
                     geom = "text")

histexample

And, if we look at the bin centers of ggplot_build():

hexDat = ggplot_build(hexHist)$data[[1]] 
hexHist2 = hexHist + annotate("text", hexDat$x, hexDat$y, label = "o")

histexample2

I've been told that some tiles that are supposed to be there aren't being plotted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions