{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A trellis scatterplot showing Horsepower and Miles per gallons, faceted by binned values of Acceleration.", "background": "white", "padding": 5, "data": [ { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [ { "type": "extent", "field": "Acceleration", "signal": "bin_maxbins_6_Acceleration_extent" }, { "type": "bin", "field": "Acceleration", "as": [ "bin_maxbins_6_Acceleration", "bin_maxbins_6_Acceleration_end" ], "signal": "bin_maxbins_6_Acceleration_bins", "extent": {"signal": "bin_maxbins_6_Acceleration_extent"}, "maxbins": 6 }, { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])" } ] }, { "name": "row_domain", "source": "source_0", "transform": [ { "type": "aggregate", "groupby": [ "bin_maxbins_6_Acceleration", "bin_maxbins_6_Acceleration_end" ] } ] } ], "signals": [ {"name": "child_width", "value": 200}, {"name": "child_height", "value": 200} ], "layout": { "padding": 20, "offset": {"rowTitle": 10}, "columns": 1, "bounds": "full", "align": "all" }, "marks": [ { "name": "row-title", "type": "group", "role": "row-title", "title": { "text": "Acceleration (binned)", "orient": "left", "style": "guide-title", "offset": 10 } }, { "name": "row_header", "type": "group", "role": "row-header", "from": {"data": "row_domain"}, "sort": { "field": "datum[\"bin_maxbins_6_Acceleration\"]", "order": "ascending" }, "title": { "text": { "signal": "!isValid(parent[\"bin_maxbins_6_Acceleration\"]) || !isFinite(+parent[\"bin_maxbins_6_Acceleration\"]) ? \"null\" : format(parent[\"bin_maxbins_6_Acceleration\"], \"\") + \" – \" + format(parent[\"bin_maxbins_6_Acceleration_end\"], \"\")" }, "orient": "left", "style": "guide-label", "frame": "group", "offset": 10 }, "encode": {"update": {"height": {"signal": "child_height"}}}, "axes": [ { "scale": "y", "orient": "left", "grid": false, "title": "Miles_per_Gallon", "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": "Horsepower", "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": [ "bin_maxbins_6_Acceleration", "bin_maxbins_6_Acceleration_end" ] } }, "sort": { "field": ["datum[\"bin_maxbins_6_Acceleration\"]"], "order": ["ascending"] }, "encode": { "update": { "width": {"signal": "child_width"}, "height": {"signal": "child_height"} } }, "marks": [ { "name": "child_marks", "type": "symbol", "style": ["point"], "from": {"data": "facet"}, "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"} } } } ], "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": "Horsepower"}, "range": [0, {"signal": "child_width"}], "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "Miles_per_Gallon"}, "range": [{"signal": "child_height"}, 0], "nice": true, "zero": true } ] }