Last active
April 27, 2020 03:16
-
-
Save jaidevd/1e751bfcf150ac85be0a90f89c5f9a4c to your computer and use it in GitHub Desktop.
Vega Heatmap
This file contains hidden or 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/v5.json", | |
"description": "A heatmap showing average daily temperatures in Seattle for each hour of the day.", | |
"width": 800, | |
"height": 500, | |
"padding": 5, | |
"title": { | |
"text": "Seattle Annual Temperatures", | |
"anchor": "middle", | |
"fontSize": 16, | |
"offset": 4 | |
}, | |
"scales": [ | |
{ | |
"name": "x", | |
"type": "time", | |
"domain": {"data": "temperature", "field": "date"}, | |
"range": "width" | |
}, | |
{ | |
"name": "y", | |
"type": "band", | |
"domain": {"data": "temperature", "field": "time"}, | |
"range": "height" | |
}, | |
{ | |
"name": "color", | |
"type": "linear", | |
"range": {"scheme": "Viridis"}, | |
"domain": {"data": "temperature", "field": "temp"}, | |
"reverse": false, | |
"zero": false, "nice": true | |
} | |
], | |
"axes": [ | |
{"orient": "bottom", "scale": "x", "domain": false, "title": "Month"}, | |
{ | |
"orient": "left", "scale": "y", "domain": false, "title": "Hour" | |
} | |
], | |
"legends": [ | |
{ | |
"fill": "color", | |
"type": "gradient", | |
"title": "Avg. Temp (°F)", | |
"titleFontSize": 12, | |
"titlePadding": 4, | |
"gradientLength": {"signal": "height - 16"} | |
} | |
], | |
"marks": [ | |
{ | |
"type": "rect", | |
"from": {"data": "temperature"}, | |
"encode": { | |
"enter": { | |
"x": {"scale": "x", "field": "date"}, | |
"y": {"scale": "y", "field": "time"}, | |
"width": {"value": 5}, | |
"height": {"scale": "y", "band": 1} | |
}, | |
"update": { | |
"fill": {"scale": "color", "field": "temp"} | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment