densCols {grDevices} | R Documentation |
densCols
produces a vector containing colors which encode the
local densities at each point in a scatterplot.
densCols(x, y = NULL, nbin = 128, bandwidth, colramp = colorRampPalette(blues9[-(1:3)])) blues9
x, y |
the |
nbin |
numeric vector of length one (for both directions) or two
(for x and y separately) specifying the number of equally spaced
grid points for the density estimation; directly used as
|
bandwidth |
numeric vector (length 1 or 2) of smoothing bandwidth(s).
If missing, a more or less useful default is used. |
colramp |
function accepting an integer |
densCols
computes and returns the set of colors that will be
used in plotting, calling bkde2D(*,
bandwidth, gridsize=nbin, ..)
from package KernSmooth.
blues9
is a set of 9 color shades of blue used as the default in
plotting.
densCols
returns a vector of length nrow(x)
that
contains colors to be used in a subsequent scatterplot. Each color
represents the local density around the corresponding point.
Florian Hahne at FHCRC, originally
bkde2D
from package KernSmooth;
further, smoothScatter()
(package graphics) which
builds on the same computations as densCols
.
x1 <- matrix(rnorm(1e3), ncol=2) x2 <- matrix(rnorm(1e3, mean=3, sd=1.5), ncol=2) x <- rbind(x1,x2) dcols <- densCols(x) graphics::plot(x, col = dcols, pch=20, main = "n = 1000")