I am producing a color density scatterplot in R using the smoothScatter()
function.
Example:
## A largish data set
n <- 10000
x1 &
Here is an answer that relies on fields::imageplot
and some fiddling with par(mar)
to get the margins correct
fudgeit <- function(){
xm <- get('xm', envir = parent.frame(1))
ym <- get('ym', envir = parent.frame(1))
z <- get('dens', envir = parent.frame(1))
colramp <- get('colramp', parent.frame(1))
fields::image.plot(xm,ym,z, col = colramp(256), legend.only = T, add =F)
}
par(mar = c(5,4,4,5) + .1)
smoothScatter(x, nrpoints = 0, postPlotHook = fudgeit)
You can fiddle around with image.plot to get what you want and look at ?bkde2D
and the transformation
argument to smoothScatter
to get an idea of what the colours represent.