I'm trying to create a normal hexbin plot but instead of coloring the plot by count, the default, I would like to have it colored by the average value of a third variable. In my particular case, I cannot use the stat_summary_hex function.
library(ggplot2)
library(hexbin)
x <- rnorm(1e4, 0, 5)
y <- rnorm(1e4, 0, 10)
z <- rnorm(1e4, 20, 1)
data.frame(x, y, z) %>%
ggplot(mapping = aes(x = x, y = y, z = z)) +
geom_hex(bins = 20)