Weekly Weather Plot
Inspired by this Vega example. Weekly weather data plot representing high/low ranges of record temperatures (light grey), average temperatures (dark grey), and both predicted and observed temperatures (black) for the given week. The first five days have high/low ranges of observed temperatures, and the last five days have ranges of predicted temperatures, where the upper barbell represents the range of high temperature predictions and the lower barbell represents the range of low temperature predictions. Created by @melissatdiamond.
View this example in the online editor
Vega-Lite JSON Specification
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"description": "A layered bar chart with floating bars representing weekly weather data",
"title": {
"text": "Weekly Weather Observations and Predictions",
"frame": "bounds"
},
"data": {
"url": "data/weather.json"
},
"width": 250,
"height": 200,
"encoding": {
"x": {
"field": "id",
"type": "ordinal",
"axis": {
"domain": false,
"ticks": false,
"labels": false,
"title": "Day",
"titlePadding": 25,
"orient": "top"
}
}
},
"layer": [
{
"mark": {
"type": "bar",
"style": "box"
},
"encoding": {
"y": {
"field": "record.low",
"type": "quantitative",
"scale": {"domain": [10, 70]},
"axis": {"title": "Temperature (F)"}
},
"y2": {"field": "record.high"},
"size": {"value": 20},
"color": {"value": "#ccc"}
}
},
{
"mark": {
"type": "bar",
"style": "box"
},
"encoding": {
"y": {
"field": "normal.low",
"type": "quantitative"
},
"y2": {"field": "normal.high"},
"size": {"value": 20},
"color": {"value": "#999"}
}
},
{
"mark": {"type": "bar", "style": "box"},
"encoding": {
"y": {
"field": "actual.low",
"type": "quantitative"
},
"y2": {"field": "actual.high"},
"size": {"value": 12},
"color": {"value": "#000"}
}
},
{
"mark": {"type": "bar", "style": "box"},
"encoding": {
"y": {
"field": "forecast.low.low",
"type": "quantitative"
},
"y2": {"field": "forecast.low.high"},
"size": {"value": 12},
"color": {"value": "#000"}
}
},
{
"mark": {"type": "bar", "style": "box"},
"encoding": {
"y": {
"field": "forecast.low.high",
"type": "quantitative"
},
"y2": {"field": "forecast.high.low"},
"size": {"value": 3},
"color": {"value": "#000"}
}
},
{
"mark": {"type": "bar", "style": "box"},
"encoding": {
"y": {
"field": "forecast.high.low",
"type": "quantitative"
},
"y2": {"field": "forecast.high.high"},
"size": {"value": 12},
"color": {"value": "#000"}
}
},
{
"mark": {"type": "text", "align": "center", "baseline": "bottom", "y": -5},
"encoding": {
"text": {
"field": "day",
"type": "nominal"
}
}
}
]
}