{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ {"name": "source_0", "url": "data/cars.json", "format": {"type": "json"}}, { "name": "data_0", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "aggregate", "groupby": [], "ops": ["stdev", "mean"], "fields": ["Miles_per_Gallon", "Miles_per_Gallon"], "as": ["extent_Miles_per_Gallon", "center_Miles_per_Gallon"] }, { "type": "formula", "expr": "datum[\"center_Miles_per_Gallon\"] + datum[\"extent_Miles_per_Gallon\"]", "as": "upper_Miles_per_Gallon" }, { "type": "formula", "expr": "datum[\"center_Miles_per_Gallon\"] - datum[\"extent_Miles_per_Gallon\"]", "as": "lower_Miles_per_Gallon" }, { "type": "filter", "expr": "isValid(datum[\"lower_Miles_per_Gallon\"]) && isFinite(+datum[\"lower_Miles_per_Gallon\"])" } ] } ], "marks": [ { "name": "layer_0_marks", "type": "symbol", "style": ["point"], "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Miles_per_Gallon: \" + (format(datum[\"Miles_per_Gallon\"], \"\"))" }, "x": {"scale": "x", "field": "Horsepower"}, "y": {"scale": "y", "field": "Miles_per_Gallon"} } } }, { "name": "layer_1_layer_0_marks", "type": "rect", "style": ["rect", "errorband-band"], "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.3}, "fill": {"value": "#4c78a8"}, "tooltip": { "signal": "{\"Mean of Miles per Gallon\": format(datum[\"center_Miles_per_Gallon\"], \"\"), \"Mean + stdev of Miles per Gallon\": format(datum[\"upper_Miles_per_Gallon\"], \"\"), \"Mean - stdev of Miles per Gallon\": format(datum[\"lower_Miles_per_Gallon\"], \"\")}" }, "description": { "signal": "\"Miles per Gallon: \" + (format(datum[\"lower_Miles_per_Gallon\"], \"\")) + \"; upper_Miles_per_Gallon: \" + (format(datum[\"upper_Miles_per_Gallon\"], \"\")) + \"; Mean of Miles per Gallon: \" + (format(datum[\"center_Miles_per_Gallon\"], \"\")) + \"; Mean + stdev of Miles per Gallon: \" + (format(datum[\"upper_Miles_per_Gallon\"], \"\")) + \"; Mean - stdev of Miles per Gallon: \" + (format(datum[\"lower_Miles_per_Gallon\"], \"\"))" }, "x": {"field": {"group": "width"}}, "x2": {"value": 0}, "y": {"scale": "y", "field": "lower_Miles_per_Gallon"}, "y2": {"scale": "y", "field": "upper_Miles_per_Gallon"} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": {"data": "data_0", "field": "Horsepower"}, "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "Miles_per_Gallon"}, {"data": "data_1", "field": "lower_Miles_per_Gallon"}, {"data": "data_1", "field": "upper_Miles_per_Gallon"} ] }, "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": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Miles per Gallon", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }