⚠ Early release: v0.3.2.sophistry is not ready for production use. Until 1.0, any minor release may break the API; expect missing features and bugs too.Stability and versioning
Scatter and distributions
Marks that show individual observations or summarise how they spread. Start with ScatterWithErrorBars, then StripAndSwarm and BoxAndViolin. The point-heavy marks here (Scatter, Strip, Beeswarm, Rug) always paint as one batched layer, with hover still resolved per point; see Batched rendering.
Scatter with error bars
Measurements as points with a symmetric error bar on each: every point fades in where it stands and its bar grows out of it, left to right.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Axes, Stage, usePlayer } from "@sophistry/solidjs";import { ErrorBar, Scatter } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const measurements = [ { x: 1, y: 2.1, err: 0.5 }, { x: 2, y: 3.4, err: 0.8 }, { x: 3, y: 3.9, err: 0.4 }, { x: 4, y: 5.2, err: 0.9 }, { x: 5, y: 5.6, err: 0.6 }, { x: 6, y: 7.1, err: 0.7 },];
export default function ScatterWithErrorBars() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2 })); });
return ( <Stage units={12}> <Axes xRange={[0, 7, 1]} yRange={[0, 10, 2]} width={9} height={5}> <ErrorBar data={measurements} x="x" y="y" yError="err" progress={progress} stagger={0.5} /> <Scatter data={measurements} x="x" y="y" radius={0.12} progress={progress} stagger={0.5} /> </Axes> </Stage> );}Regression with a confidence band
One least-squares fit per series, each with the 95% band of its mean, narrowest at the centre of its data. The series channel splits the fits and colours fits and points alike, keyed by one legend; every line and band sweeps in along x behind one front.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Regression, Scatter } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const students = Array.from({ length: 24 }, (_, i) => { const online = i >= 12; const hours = 1 + (i % 12) * 0.7 + (online ? 0.3 : 0); const noise = Math.sin((i + 1) * 12.9898) * 5; return online ? { course: "online", hours, score: 40 + hours * 5.5 + noise } : { course: "lecture", hours, score: 52 + hours * 3.5 + noise };});
export default function RegressionBand() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.2} // The top legend and the y title sit above height: leave them room. center={{ x: 0, y: -0.4 }} xLabel="hours" yLabel="score" grid="y" legend="top" progress={shown} > <Regression data={students} x="hours" y="score" series="course" /> <Scatter data={students} x="hours" y="score" series="course" stagger={0.5} /> </Chart> </Stage> );}Robust LOESS smooth
A local regression with its 95% band, through a noisy daily series with a few bad readings. The plain smooth bends toward the outliers and its band balloons; robustness iterations re-weight them away.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Regression, Scatter } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const readings = Array.from({ length: 60 }, (_, day) => { const trend = 10 + 6 * Math.sin(day / 9); const noise = 1.2 * Math.sin((day + 1) * 12.9898); const glitch = day % 17 === 8 ? 14 : 0; return { day, value: trend + noise + glitch };});
export default function RobustLoess() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.2} center={{ x: -0.6, y: -0.2 }} xLabel="day" grid="y" color={{ domain: ["plain", "robust"] }} progress={shown} > <Regression data={readings} x="day" y="value" method="loess" bandwidth={0.35} series={() => "plain"} /> <Regression data={readings} x="day" y="value" method="loess" bandwidth={0.35} robust series={() => "robust"} /> <Scatter data={readings} x="day" y="value" radius={0.05} color="#9aa0a6" /> </Chart> </Stage> );}Strip plot and beeswarm
Every observation as a dot, coloured by cohort through the chart's series scale and legend. A strip plot spreads them by seeded jitter (the same on every frame); a beeswarm packs them so none overlap. Dots appear in place, low values first.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { Beeswarm, Chart, Strip } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const arms = ["placebo", "low dose", "high dose"];const trials = arms.flatMap((arm, a) => Array.from({ length: 30 }, (_, i) => { const u = (Math.sin((i + 1) * 12.9898 + a * 7.1) + Math.sin((i + 1) * 4.1414)) / 2; const cohort = i % 3 === 0 ? "2025" : "2024"; return { arm, cohort, response: 40 + a * 8 + u * 12 }; }),);
export default function StripAndSwarm() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={16}> <Chart width={6} height={4} center={{ x: -4, y: 0 }} grid="y" legend="top" progress={shown} > <Strip data={trials} category="arm" value="response" series="cohort" stagger={0.6} /> </Chart> <Chart width={6} height={4} center={{ x: 4, y: 0 }} grid="y" legend="top" progress={shown} > <Beeswarm data={trials} category="arm" value="response" series="cohort" radius={0.06} stagger={0.6} /> </Chart> <Text text="Strip" x={-4} y={-3.2} fontSize={0.4} /> <Text text="Beeswarm" x={4} y={-3.2} fontSize={0.4} /> </Stage> );}Box and violin plots
The same three samples summarised two ways: quartile boxes that open out of their medians, and kernel-density violins that widen out of their centre lines.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, Text, usePlayer } from "@sophistry/solidjs";import { BoxPlot, ViolinPlot } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// Deterministic, roughly bell-shaped samples: sums of a few sine-hash "uniforms".const sample = (seed: number, center: number, spread: number, n = 60) => Array.from({ length: n }, (_, i) => { let sum = 0; for (let k = 1; k <= 4; k++) { sum += (Math.sin((i + 1) * k * 12.9898 + seed * 78.233) + 1) / 2; } return center + (sum - 2) * spread; });
const groups = [ { name: "control", values: sample(1, 5, 2) }, { name: "dose A", values: [...sample(2, 7, 1.5), 12.5] }, { name: "dose B", values: sample(3, 6, 3) },];
export default function BoxAndViolin() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={16}> <BoxPlot data={groups} values="values" label="name" yRange={[0, 14, 2]} width={6} height={4.2} center={{ x: -4.2, y: 0 }} progress={progress} stagger={0.4} /> <ViolinPlot data={groups} values="values" label="name" yRange={[0, 14, 2]} width={6} height={4.2} center={{ x: 4.2, y: 0 }} progress={progress} stagger={0.4} /> <Text text="BoxPlot" x={-4.2} y={-3.2} fontSize={0.4} /> <Text text="ViolinPlot" x={4.2} y={-3.2} fontSize={0.4} /> </Stage> );}Grouped box plots
Box plots split by a series, seaborn's hue: the boxes sharing a dose stand side by side in its slot, and a dodged strip of the raw readings sits over each box. One colour scale and one legend serve both.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { BoxPlot, Strip } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const doses = ["low", "mid", "high"];const arms = ["placebo", "drug"];// Raw readings: 14 per dose and arm, from a deterministic sine hash.const readings = doses.flatMap((dose, d) => arms.flatMap((arm, a) => Array.from({ length: 14 }, (_, i) => ({ dose, arm, score: 40 + a * (6 + 6 * d) + 9 * Math.sin((i + 1) * (d + 2) * (a + 3) * 1.7), })), ),);// The same readings, one sample per box.const groups = doses.flatMap((dose) => arms.map((arm) => ({ dose, arm, scores: readings .filter((r) => r.dose === dose && r.arm === arm) .map((r) => r.score), })),);
export default function GroupedBoxes() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <BoxPlot data={groups} values="scores" label="dose" series="arm" fillOpacity={0.35} width={7} height={4.2} center={{ x: -0.6, y: 0 }} yRange={[20, 80, 10]} stagger={0.4} progress={shown} > <Strip data={readings} category="dose" value="score" series="arm" dodge width={0.5} radius={0.045} /> </BoxPlot> </Stage> );}Density with a rug
One kernel density estimate per series (morning and evening waits, from one long-format sample), both sweeping in along x behind one front, with the raw sample as a rug of ticks standing on the axis, in the same series colours, drawn in value order.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Density, Rug } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
// Two overlapping clusters, from a deterministic sine hash.const waits = Array.from({ length: 80 }, (_, i) => { const u = (Math.sin((i + 1) * 12.9898) + Math.sin((i + 1) * 78.233)) / 2; return i % 3 === 0 ? { when: "evening", minutes: 7.5 + u * 1.5 } : { when: "morning", minutes: 3.5 + u * 1.8 };});
export default function DensityAndRug() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4} xLabel="minutes" grid="y" legend="top" progress={shown} > <Density data={waits} x="minutes" series="when" /> <Rug data={waits} value="minutes" series="when" stagger={0.6} /> </Chart> </Stage> );}Ridgeline
One Density over long-format rows, with series="month" and row: each month's curve stands on its own row of a band y axis and rises into the one above, so the shift in the distribution month by month reads as a landscape. The month axis stands at the left edge, clear of the curves, though the temperatures cross zero, and reveal="x" uncovers every ridge behind one shared front.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { Chart, Density } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const months = ["Jan", "Mar", "May", "Jul", "Sep", "Nov"];// Daily highs in °C for a continental climate: winter months straddle zero.const centre = [-4, 3, 15, 24, 16, 2];// A deterministic, roughly bell-shaped sample around each month's centre.const rows = months.flatMap((month, m) => Array.from({ length: 60 }, (_, i) => { let sum = 0; for (let k = 1; k <= 3; k++) sum += Math.sin((i + 1) * k * 12.9898 + m * 4.1); return { month, temp: centre[m] + sum * 2.5 }; }),);const palette = [ "#4c78a8", "#72b7b2", "#54a24b", "#eeca3b", "#f58518", "#b279a2",];
export default function Ridgeline() { const { play } = usePlayer(); const shown = track(0); onSettled(() => { void play(draw(shown, { duration: 2.5 })); });
return ( <Stage units={12}> <Chart width={8} height={4.5} xLabel="°C" // One clip front sweeps left to right across every ridge. reveal="x" // The rows already name the months, so no legend. color={{ domain: months, range: palette }} legend={false} progress={shown} > <Density data={rows} x="temp" series="month" row rowHeight={1.5} fillOpacity={0.6} /> </Chart> </Stage> );}Parallel coordinates
Four car measurements side by side: each car is a line across the axes, drawn left to right once the axes are in.
4 collapsed lines
import { draw, track } from "@sophistry/core";import { Stage, usePlayer } from "@sophistry/solidjs";import { ParallelCoordinates } from "@sophistry/solidjs/charts";import { onSettled } from "solid-js";
const cars = [ { mpg: 18, hp: 150, kg: 1590, s: 11.5 }, { mpg: 15, hp: 198, kg: 1950, s: 10.0 }, { mpg: 24, hp: 95, kg: 1160, s: 15.0 }, { mpg: 27, hp: 88, kg: 1020, s: 14.5 }, { mpg: 31, hp: 67, kg: 900, s: 19.0 }, { mpg: 36, hp: 58, kg: 800, s: 18.5 }, { mpg: 21, hp: 110, kg: 1300, s: 14.0 }, { mpg: 13, hp: 215, kg: 2100, s: 9.5 },];
export default function ParallelCoordinatesExample() { const { play } = usePlayer(); const progress = track(0);
onSettled(() => { void play(draw(progress, { duration: 2.5 })); });
return ( <Stage units={10}> <ParallelCoordinates data={cars} axes={[ { value: "mpg", label: "mpg" }, { value: "hp", label: "horsepower" }, { value: "kg", label: "weight (kg)" }, { value: "s", label: "0–60 (s)" }, ]} color={(d) => (d.mpg >= 25 ? "#3fb68b" : "#e07a5f")} width={7} height={3.6} center={{ x: 0.3, y: -0.3 }} progress={progress} tooltip /> </Stage> );}