Vega-Lite Template Gallery
Follow ______ on twitter.
Vega-Lite Template Gallery
Another Link
Toggle Theme
Submit a Vega-Lite diagram template
Open main menu
6.1.1 Correlation in data analysis
Code
{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Scatterplots showing positive, negative, and no-correlation scenarios for two variables.", "hconcat": [ { "title": "Perfect Positive Correlation", "width": 200, "height": 200, "data": { "values": [ { "x": 1, "y": 1.1 }, { "x": 2, "y": 1.9 }, { "x": 3, "y": 3.1 }, { "x": 4, "y": 4 }, { "x": 5, "y": 5.1 }, { "x": 6, "y": 5.9 }, { "x": 7, "y": 7 }, { "x": 8, "y": 7.9 }, { "x": 9, "y": 9.1 }, { "x": 10, "y": 10.1 } ] }, "mark": "point", "encoding": { "x": { "field": "x", "type": "quantitative", "title": "Variable X" }, "y": { "field": "y", "type": "quantitative", "title": "Variable Y" } } }, { "title": "Perfect Negative Correlation", "width": 200, "height": 200, "data": { "values": [ { "x": 1, "y": 10.1 }, { "x": 2, "y": 9.1 }, { "x": 3, "y": 8 }, { "x": 4, "y": 7 }, { "x": 5, "y": 6 }, { "x": 6, "y": 5.1 }, { "x": 7, "y": 4 }, { "x": 8, "y": 3.1 }, { "x": 9, "y": 2 }, { "x": 10, "y": 1.1 } ] }, "mark": "point", "encoding": { "x": { "field": "x", "type": "quantitative", "title": "Variable X" }, "y": { "field": "y", "type": "quantitative", "title": "Variable Y" } } }, { "title": "No Correlation", "width": 200, "height": 200, "data": { "values": [ { "x": 1, "y": 5.1 }, { "x": 2, "y": 3.1 }, { "x": 3, "y": 7 }, { "x": 4, "y": 4 }, { "x": 5, "y": 6.1 }, { "x": 6, "y": 2.9 }, { "x": 7, "y": 8 }, { "x": 8, "y": 5.9 }, { "x": 9, "y": 1 }, { "x": 10, "y": 9.1 } ] }, "mark": "point", "encoding": { "x": { "field": "x", "type": "quantitative", "title": "Variable X" }, "y": { "field": "y", "type": "quantitative", "title": "Variable Y" } } } ] }
Copy
Update Vega-Lite
Reset
Vega-Lite Chart