A lightweight package for grouping 2D data into regular bins.

Primarily for plotting, but note that this package does not contain any plotting code, just calculations.


Representation of an ellipse.

  • center: center

  • d1: conjugate axis 1

  • d2: conjugate axis 2

Parametrically, the ellipse is the points @. center + d1 * cos(θ) + d2 * sin(θ) for real numbers θ.


Representation of a point, for internal use. Use point to construct.


bin(bin, xy)

Find the bin that contains xy in grid.

The return value is opaque and should be used in conjuction with grid.

Valid values for xy are 2-element tuples and AbstractVectors, SVector{2} is preferred.


bin_area(T, grid)

Calculate the area of a bin in grid using type T (default = Float64).

Note: all bins in a grid have the same area.

bin_bivariate(x, x_boundaries, y, y_boundaries)

Bin bivariate data x, y using the given boundaries.

Return a BinnedBivariate object. See get_x_y_w.

circle(center, r)

Convenience function to create a circle. Internal.

get_x_y_w(bb; threshold, scale)

Return an iterator that yields (x, y, w) triplets, keeping only w ≥ threshold.

When threshold == 0, ws sum to 1, but this is not maintained. The purpose is to remove outliers for plots, with threshold = 1e-3 or similar.

inner_ellipse(grid, bin)

inner_ellipse(T, grid, bin)

Return the Ellipse that can be inscribed into a bin.

Uses element type T (default = Float64).

nice_quantiles(xs, N; relative_threshold)

Make “nice” quantile boundaries from univariate data, using the following algorithm:

  1. quantiles 1/(N+1), 2/(N+1), …, N/(N+1) are calculated

  2. for quantiles which are closer than (maximum(x) - minimum(x)) * relative_threshold,

only one is kept

This algorithm is a heuristic designed for binning data that may pile up at various locations (edges etc).

point(x, y)

Convenience function to construct a point from two coordinates. Internal.

vertices(grid, bin)

vertices(T, grid, bin)

Return the vertices of bin in grid as a Tuple of coordinates (xy pairs).

Uses element type T (default = Float64).