{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A scatterplot showing average horsepower and displacement for cars from different origins.", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["Origin"], "ops": ["mean", "mean"], "fields": ["Horsepower", "Displacement"], "as": ["mean_Horsepower", "mean_Displacement"] }, { "type": "filter", "expr": "isValid(datum[\"mean_Horsepower\"]) && isFinite(+datum[\"mean_Horsepower\"]) && isValid(datum[\"mean_Displacement\"]) && isFinite(+datum[\"mean_Displacement\"])" } ] } ], "marks": [ { "name": "marks", "type": "symbol", "style": ["point"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Mean of Horsepower: \" + (format(datum[\"mean_Horsepower\"], \"\")) + \"; Mean of Displacement: \" + (format(datum[\"mean_Displacement\"], \"\")) + \"; Origin: \" + (isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"])" }, "x": {"scale": "x", "field": "mean_Horsepower"}, "y": {"scale": "y", "field": "mean_Displacement"} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": {"data": "source_0", "field": "mean_Horsepower"}, "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "mean_Displacement"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(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(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "Mean of Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Mean of Displacement", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }