{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "data": [ { "name": "source_0", "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/iris.json", "format": {"type": "json"}, "transform": [ { "type": "fold", "fields": ["petalWidth", "petalLength", "sepalWidth", "sepalLength"], "as": ["Measurement_type", "value"] }, { "type": "kde", "field": "value", "bandwidth": 0.3, "extent": [0, 8], "groupby": ["Measurement_type"], "as": ["value", "density"] } ] }, { "name": "row_domain", "source": "source_0", "transform": [{"type": "aggregate", "groupby": ["Measurement_type"]}] } ], "signals": [ {"name": "child_width", "value": 300}, {"name": "child_height", "value": 50} ], "layout": { "padding": 20, "offset": {"rowTitle": 10}, "columns": 1, "bounds": "full", "align": "all" }, "marks": [ { "name": "row-title", "type": "group", "role": "row-title", "title": { "text": "Measurement_type", "orient": "left", "style": "guide-title", "offset": 10 } }, { "name": "row_header", "type": "group", "role": "row-header", "from": {"data": "row_domain"}, "sort": {"field": "datum[\"Measurement_type\"]", "order": "ascending"}, "title": { "text": { "signal": "isValid(parent[\"Measurement_type\"]) ? parent[\"Measurement_type\"] : \"\"+parent[\"Measurement_type\"]" }, "orient": "left", "style": "guide-label", "frame": "group", "offset": 10 }, "encode": {"update": {"height": {"signal": "child_height"}}}, "axes": [ { "scale": "y", "orient": "left", "grid": false, "title": "density", "labelOverlap": true, "tickCount": {"signal": "ceil(child_height/40)"}, "zindex": 0 } ] }, { "name": "column_footer", "type": "group", "role": "column-footer", "encode": {"update": {"width": {"signal": "child_width"}}}, "axes": [ { "scale": "x", "orient": "bottom", "grid": false, "title": "value", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(child_width/40)"}, "zindex": 0 } ] }, { "name": "cell", "type": "group", "style": "cell", "from": { "facet": { "name": "facet", "data": "source_0", "groupby": ["Measurement_type"] } }, "sort": { "field": ["datum[\"Measurement_type\"]"], "order": ["ascending"] }, "encode": { "update": { "width": {"signal": "child_width"}, "height": {"signal": "child_height"} } }, "marks": [ { "name": "child_marks", "type": "area", "style": ["area"], "sort": {"field": "datum[\"value\"]"}, "from": {"data": "facet"}, "encode": { "update": { "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "description": { "signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; density: \" + (format(datum[\"density\"], \"\"))" }, "x": {"scale": "x", "field": "value"}, "y": {"scale": "y", "field": "density"}, "y2": {"scale": "y", "value": 0}, "defined": { "signal": "isValid(datum[\"value\"]) && isFinite(+datum[\"value\"]) && isValid(datum[\"density\"]) && isFinite(+datum[\"density\"])" } } } } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(child_width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(child_height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 } ] } ], "scales": [ { "name": "x", "type": "linear", "domain": {"data": "source_0", "field": "value"}, "range": [0, {"signal": "child_width"}], "nice": true, "zero": false }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "density"}, "range": [{"signal": "child_height"}, 0], "nice": true, "zero": true } ] }