Created
February 9, 2024 01:05
-
-
Save gopherkhan/6ef5c77459970e2a66ae1a142c052580 to your computer and use it in GitHub Desktop.
Bar Chart with Color Palette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | |
"description": "A bar chart showing the US population distribution of age groups and gender in 2000.", | |
"data": {"url": "data/population.json"}, | |
"transform": [ | |
{"filter": "datum.year == 2000"}, | |
{"calculate": "datum.sex == 2 ? 'Female' : 'Male'", "as": "gender"} | |
], | |
"width": {"step": 17}, | |
"mark": "bar", | |
"encoding": { | |
"x": {"field": "age", "type": "ordinal"}, | |
"y": { | |
"aggregate": "sum", | |
"field": "people", | |
"title": "population", | |
"stack": null | |
}, | |
"color": { | |
"field": "age", | |
"scale": { | |
"range": [ | |
"#1a73e8", | |
"#12b5cb", | |
"#e52592", | |
"#e8710a", | |
"#f9ab00", | |
"#7cb342" | |
] | |
} | |
}, | |
"opacity": {"value": 0.7} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment