Stacked histogram

A stacked histogram showing the distribution of Olympic athletes’ weights, colored by sex. Based on an example from Observable Plot.

<Plot
    height={300}
    grid
    marginLeft={40}
    color={{ legend: true }}>
    <RectY
        {...binX(
            { data: olympians, x: 'weight', fill: 'sex' },
            { y: 'count' }
        )} />
    <RuleY data={[0]} />
</Plot>

Open in Svelte playground

Improve this page
Last update at: 2025/11/24