Scatterplot with Mean and Standard Deviation Overlay
A scatterplot showing horsepower and miles per gallons for various cars.
View this example in the online editor
Vega-Lite JSON Specification
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
"data": {"url": "data/cars.json"},
"layer": [
{
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
"y": {"field": "Miles_per_Gallon", "type": "quantitative"}
}
},
{
"mark": {"type": "errorband", "extent": "stdev", "opacity": 0.2},
"encoding": {
"y": {
"field": "Miles_per_Gallon",
"type": "quantitative",
"title": "Miles per Gallon"
}
}
},
{
"mark": "rule",
"encoding": {
"y": {
"field": "Miles_per_Gallon",
"type": "quantitative",
"aggregate": "mean"
}
}
}
]
}