Note
Go to the end to download the full example code.
Hexbin density
Hexagonal 2-D binning of a point cloud, colored by count.

Live figure — pick a tool, then zoom, pan, point-pick or annotate. Nothing is active until a tool is selected.
View this figure’s Vega export ↗ — the raw JSON spec, rendered live by a real Vega engine.
View this figure’s Vega-Lite export ↗ — the raw JSON spec(s), rendered live by a real Vega-Lite engine.
import numpy as np
import plotpress
rng = np.random.default_rng(0)
x = rng.normal(size=8000)
y = x * 0.6 + rng.normal(size=8000)
fig, ax = plotpress.subplots()
hb = ax.hexbin(x, y, gridsize=30, cmap="viridis")
ax.set_title("hexbin")
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.colorbar(hb, ax=ax)
Total running time of the script: (0 minutes 0.140 seconds)