Thursday, March 3, 2016

Bivariate plots in R with many many pairs

Bivariate plots with many many pairs

Think that we need to plot many pairs, e.g. comparing A vs. G. What we can do in R:

#generate two correlated variables
a=rnorm(1000000)
b=a+rnorm(a)

plot is rather horrible






















plot(a,b)

We can draw a map with level curves
 require(MASS)
 contour(kde2d(a,b))


But I find that hexagonal binning is even nicer (and very fast !!)
require(hexbin)
tt=hexbin(a,b)
plot(tt)

Finally, we have persp:
persp(kde2d(a,b))

No comments:

Post a Comment