hist2d: Bin a set of (x,y) points into a 2D histogram

Description Usage Arguments Details Value Notes See Also Examples

View source: R/plot_contour.R

Description

hist2d produce a 2D histogram from x, y points.

Usage

1
hist2d(x, y, npix = 25, lims = c(range(x), range(y)), prob = FALSE)

Arguments

npix

number of bins on each axis (pixels = npix^2)

lims

Four-element vector for x, y limits of the histogram

prob

(logical) make the area under the histogram equal to 1?

Details

From an set of (x, y) positions, compute a 2D histogram. Count the number of input points falling within each pixel on and evenly spaced grid points of pix.x = i*dx, pix.y = j*dy. return this values as z.

Value

List containing components x, y, z.

Notes

The output img is a list with three components: z is a vector of nx evenly spaced x positions, y is a vector of ny evenly spaced y position, z is an nx*ny array of z values at the (x, y) coordinates.

See Also

chain_convergence, contour_matrix

Examples

1
2
3
4
5
6
n <- 1000
x <- rnorm(n)
y <- x + rnorm(n)
img <- hist2d(x, y, npix = 11)
image(img$x, img$y, log10(img$z))
points(x, y)

svdataman/tonic documentation built on Aug. 2, 2019, 3:21 p.m.