Skip to content
Vega-Lite templates

Violin Plot

Distribution comparison via violins across three groups.

Template previewVega-Lite
Rendering…

Make it your own.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": { "values": [
    {"g":"A","v":1.1},{"g":"A","v":1.4},{"g":"A","v":1.7},{"g":"A","v":2.1},{"g":"A","v":1.3},
    {"g":"B","v":2.4},{"g":"B","v":2.7},{"g":"B","v":3.0},{"g":"B","v":3.3},{"g":"B","v":2.8},
    {"g":"C","v":0.9},{"g":"C","v":1.0},{"g":"C","v":1.2},{"g":"C","v":1.1},{"g":"C","v":0.8}
  ]},
  "transform": [
    { "density":"v", "groupby":["g"] }
  ],
  "mark": {"type":"area","orient":"horizontal"},
  "encoding": {
    "y":{"field":"value","type":"quantitative"},
    "x":{"field":"density","type":"quantitative","stack":"center","axis":null},
    "color":{"field":"g","type":"nominal"},
    "column":{"field":"g","type":"nominal","header":{"title":null,"labelOrient":"bottom"},"spacing":0}
  },
  "width":80,"height":220,"config":{"view":{"stroke":null}}
}