Using stat_binhex() with ggpairs()

ggally, ggplot2, r

Solution

set.seed(1)
library(GGally)
library(hexbin)
df <- as.data.frame(matrix(rnorm(20*3), ncol=3))
p <- ggpairs(df, lower="blank")
seq <- 1:ncol(df)
for (x in seq)
  for (y in seq) 
    if (y>x) 
      p <- putPlot(p, ggplot(df, aes_string(x=names(df)[x],y=names(df)[y])) + stat_binhex(bins=4), y,x)
p

Problem

I would like to use the `stat_binhex()` statistic from `ggplot2` with the `ggpairs()` function (`GGally` R package). For example, I would like to use `stat_binhex()` in this plot instead of `geom_point()`. Is that possible? Thanks for your help!

Original source