Stacked Density Estimates
View this example in the online editor
Vega-Lite JSON Specification
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"title": "Distribution of Body Mass of Penguins",
"width": 400,
"height": 80,
"data": {
"url": "data/penguins.json"
},
"mark": "area",
"transform": [
{
"density": "Body Mass (g)",
"groupby": ["Species"],
"extent": [2500, 6500]
}
],
"encoding": {
"x": {"field": "value", "type": "quantitative", "title": "Body Mass (g)"},
"y": {"field": "density", "type": "quantitative", "stack": "zero"},
"color": {"field": "Species", "type": "nominal"}
}
}