Skip to content
Vega-Lite templates

Density Contour

2D density contour estimation.

Template previewVega-Lite
Rendering…

Make it your own.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"x":0.1,"y":0.2},{"x":0.4,"y":0.3},{"x":0.6,"y":0.5},{"x":0.7,"y":0.4},
      {"x":1.0,"y":0.9},{"x":1.2,"y":1.1},{"x":1.4,"y":1.0},{"x":1.6,"y":1.3},
      {"x":1.8,"y":1.5},{"x":2.0,"y":1.7},{"x":2.2,"y":2.0},{"x":2.4,"y":2.2},
      {"x":2.6,"y":2.5},{"x":2.7,"y":2.4},{"x":2.9,"y":2.7},{"x":3.0,"y":2.9}
    ]
  },
  "layer":[
    {"mark":{"type":"point","filled":true,"opacity":0.5}, "encoding": {"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}}},
    {"transform":[{"density":"y","groupby":[]}], "mark":{"type":"area","opacity":0.3,"color":"#1f47f5"},"encoding":{"x":{"field":"value","type":"quantitative"},"y":{"field":"density","type":"quantitative"}}}
  ],
  "width": 360, "height": 260
}