Hexbin — Hexagonal Density Binning
Signature
sp.hexbin(title, x_values, y_values, *, variant="basic", gridsize=20, colorscale=None, **kwargs) -> Chart
Aliases: sp.hexbin, sp.hexbins, sp.hexbin_chart, sp.hexagonal_binning, sp.build_hexbin
Description
sp.hexbin() bins a 2D scatter cloud into a regular hexagonal grid and colors each hexagon by point density (count), the standard alternative to a scatter plot once point overlap makes individual markers unreadable. Points are assigned to hexagon cells directly in pixel space using the true nearest-center rule (two candidate offset grids, closest wins), so cells tile without gaps or overlap regardless of the data’s aspect ratio. Cell color reuses the same continuous colorscale engine as heatmap() and bubble(variant="gradient") — any of viridis / plasma / inferno / magma / cividis / turbo / rdbu / blues / reds / greens works via colorscale=.
Variants
Data
x_values (list[float]) — X coordinates. y_values (list[float]) — Y coordinates.
Parameters
Themes
Returns
Chart — object with .html property and .show() method.
Parameters
Filled hexagons only, compact grid, right-side density legend.
White cell borders; count printed inside each hexagon once cells are large enough to fit text.
Hexagons drawn at 72% size with a visible gap between neighbors — a "confetti" look instead of a solid tiled surface.
Dims every cell except the densest ~15% (full opacity, white outline, count label) — draws the eye straight to the hotspots instead of the full density gradient.
Bins below min_count are skipped entirely (left transparent) instead of drawn faint - a hard threshold rather than a dimmed gradient, matching R's hexbin(mincnt=).
Each cell's count is classed into an order-of-magnitude band (ones/tens/hundreds/thousands/10 thousands), colored and sized by band, with a smaller nested hexagon inside in the previous band's color - matching R hexbin's nested/centroid styles - plus a size+color legend.
Cell color is mapped on log(count + 1) instead of the raw count, matching matplotlib's hexbin(bins="log") — compresses the huge dynamic range that skewed point clouds produce so low-density cells stay visually distinguishable instead of collapsing near zero.
Cell color encodes the average of a third variable (values=) inside each bin instead of the point count — the native equivalent of matplotlib's hexbin(C=..., reduce_C_function=numpy.mean), for when the quantity of interest isn't density itself.
White dashed cell borders over a full continuous colorscale (defaults to magma) with no plot border — matches matplotlib's hexbin(edgecolor="white", linestyle="dotted", linewidth=1.5) styling exactly.
Adds 1D density strips above and to the right of the hexbin grid — a joint-plot style combination, showing the marginal distribution of each axis alongside the 2D density.
Tessellates the scattered points into a bounded Voronoi diagram instead of a regular hex grid — each cell's fill encodes local density (values= if supplied, otherwise the inverse of the cell's own area), so density is read from irregular organic cell sizes rather than a uniform lattice. Site points are drawn as small dots on top, echoing the "particle tracking" framing of density-Voronoi science posters.
Draws the Voronoi tessellation as stroke-only outlines — no fill — overlaid across several independently-jittered site positions, so shared edges between frames build up into a dense tangled mesh in the high-density core while the sparse periphery stays a single clean web of long lines. A gray-to-red-to-orange-to-yellow ramp and soft glow pick out the densest region; short red streaks mark low-density outlier points.
Estimates a smooth 2D density field from the scattered points (a Gaussian-kernel distance field, bandwidth auto-derived from point count and plot area) and bands it into discrete iso-level cells — every cell is colored by the highest density threshold it clears, so overlapping seeds fuse into organic merged "islands" instead of staying as separate circles. Cell edges are lightly jittered per-cell for a hand-cut, faceted look, and the outermost frame borrows architectural-drawing conventions: a diagonal-hatch margin, circled grid-reference bubbles, and a data-derived "NODES" tally (seed count, band count, peak-band cell count, coverage, bandwidth).