Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using stat_binhex() with ggpairs()

Tags:

r

ggplot2

ggally

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?

enter image description here

Thanks for your help!

like image 613
vgbio24 Avatar asked Oct 02 '22 00:10

vgbio24


1 Answers

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

screenshot

like image 148
lukeA Avatar answered Oct 13 '22 12:10

lukeA