Stacked Density Estimates

View this example in the online editor

Vega-Lite JSON Specification

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {"url": "data/movies.json"},
  "width": 400,
  "height": 100,
  "transform":[
    {
      "density": "IMDB_Rating",
      "bandwidth": 0.3,
      "groupby": ["Major_Genre"],
      "extent": [0, 10],
      "counts": true,
      "steps": 50
    }
  ],
  "mark": "area",
  "encoding": {
    "x": {
      "field": "value",
      "type": "quantitative"
    },
    "y": {
      "field": "density",
      "type": "quantitative",
      "stack": true
    },
    "color": {
      "field": "Major_Genre",
      "type": "nominal",
      "scale": {"scheme": "category20"}
    }
  }
}