Three.js Scatter Plot Matrix (SPLOM) with Linked Brushing
A scatter-plot matrix in Three.js showing every pair of four features for three species, with histograms on the diagonal, linked brushing that highlights samples across all panels, and a rotating 3D scatter of any three features.
Key topics: scatter plot matrix, splom, linked brushing, multivariate data, three.js scatter plot, exploratory data analysis
Game Over
What this code does
- SPLOM: panel (row, column) plots feature[column] against feature[row], 12 scatter panels drawn by one InstancedMesh.
- Diagonal: per-species histograms of each feature show distributions and overlap.
- Linked Brushing: hovering a panel selects samples inside the brush there, and those samples light up in every other panel.
- Patterns: correlated features form diagonals, and one species separates cleanly in petal measurements but not sepal width.
- 3D Scatter: switch view and pick any three features for X/Y/Z.
- Controls: view, 3D axes, brush radius and sample count; data is synthetic and iris-like.
Related Demos
Continue Learning
JavaScript Implementation
// Scatter-plot matrix: panel (row, col) plots feature[col] on x against feature[row] on y
const dots = new THREE.InstancedMesh(new THREE.CircleGeometry(0.045, 12), new THREE.MeshBasicMaterial(), n * 12)
let k = 0
for (let r = 0; r < 4; r++) for (let c = 0; c < 4; c++) {
if (r === c) continue // diagonal → histogram
for (const row of data) {
dots.setMatrixAt(k, new THREE.Matrix4().makeTranslation(x0(c) + norm(c, row[c]) * P, y0(r) + norm(r, row[r]) * P, 0))
dots.setColorAt(k++, speciesColour(row))
}
}
// Linked brushing: pick samples near the cursor in one panel, dim every other instance