dense2d: 2D density heatmap plot

dense2dR Documentation

2D density heatmap plot

Description

Uses base R's densCols to calculate local densities at each point in a scatterplot, and then replaces them by a colored scheme, copied from Josh O'Brien posted at https://stackoverflow.com/questions/17093935/r-scatter-plot-symbol-color-represents-number-of-overlapping-points/17096661#17096661

Usage

dense2d(
  x,
  y,
  pch = 20,
  nbin = c(128, 128),
  circular = FALSE,
  xlim,
  ylim,
  colf = viridis::viridis,
  ...
)

Arguments

x

x-coordinates

y

y-coordinates

pch

pch argument to plot

nbin

number of bins for both dimensions, can be a single. number for both dimensions, or separate numbers, see argument nbins to function densCols and gridsize to bkde2D.

circular

treat x and y as circular coordinates in radian.

xlim

numeric vectors of length 2, giving the x coordinate ranges.

ylim

as xlim for y.

colf

color map function used to create a color gradient, eg. colorRampPalette or viridis.

...

arguments to plot (hint:cex can be useful).

Value

the plotted data.frame, including local densities.


raim/segmenTools documentation built on Sept. 9, 2024, 5:24 p.m.