
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(hexbin)
> 
> ## a variation on Nicholas' post to bioconductor & example(hexViewport)
> set.seed(545)
> x <- rnorm(2^15)
> y <- 3*x - .2*x^2 + rnorm(2^15)
> hbin <- hexbin(x,y)
> 
> ##
> hp <- hexViewport(hbin, newpage = TRUE)
> pushHexport(hp)
> library("grid")
> grid.rect()
> grid.xaxis()
> grid.yaxis()
> grid.hexagons(hbin, style = "centroid")
> hloess <- loess(y ~ x, data = hcell2xy(hbin), weights = hbin @ count)
> xx <- seq(hbin@xbnds[1], hbin@xbnds[2], length = 500)
> grid.lines(xx, predict(hloess, xx),
+            gp = gpar(col = 'red', lwd = 2), default.units = "native")
> popViewport()
> 
> proc.time()
   user  system elapsed 
  0.368   0.020   0.379 
