Ranged Dot Plot
A ranged dot plot that uses ‘layer’ to convey changing life expectancy for the five most populous countries (between 1955 and 2000).
View this example in the online editor
Vega-Lite JSON Specification
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A ranged dot plot that uses 'layer' to convey changing life expectancy for the five most populous countries (between 1955 and 2000).",
"data": {"url": "data/countries.json"},
"transform": [
{
"filter": {
"field": "country",
"oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]
}
},
{
"filter": {
"field": "year",
"oneOf": [1955, 2000]
}
}
],
"encoding": {
"x": {
"field": "life_expect",
"type": "quantitative",
"title": "Life Expectancy (years)"
},
"y": {
"field": "country",
"type": "nominal",
"title": "Country",
"axis": {
"offset": 5,
"ticks": false,
"minExtent": 70,
"domain": false
}
}
},
"layer": [
{
"mark": "line",
"encoding": {
"detail": {
"field": "country",
"type": "nominal"
},
"color": {"value": "#db646f"}
}
},
{
"mark": {
"type": "point",
"filled": true
},
"encoding": {
"color": {
"field": "year",
"type": "ordinal",
"scale": {
"domain": [1955, 2000],
"range": ["#e6959c", "#911a24"]
},
"title": "Year"
},
"size": {"value": 100},
"opacity": {"value": 1}
}
}
]
}