Created
November 19, 2017 05:07
-
-
Save AliciaSchep/68755433c041736e5dc6182c9990c6ab to your computer and use it in GitHub Desktop.
vegalite hconcat plus vconcat plus layer
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/v2.json", | |
"description": "Two horizonally concatenated charts that show a histogram of precipitation in Seattle and the relationship between min and max temperature.", | |
"data": { | |
"url": "data/weather.csv", | |
"format": { | |
"type": "csv" | |
} | |
}, | |
"transform": [ | |
{ | |
"filter": "datum.location === 'Seattle'" | |
} | |
], | |
"vconcat": [ | |
{"hconcat": [ | |
{"layer": [ | |
{ | |
"mark": "bar", | |
"encoding": { | |
"x": { | |
"timeUnit": "month", | |
"field": "date", | |
"type": "ordinal" | |
}, | |
"y": { | |
"aggregate": "mean", | |
"field": "precipitation", | |
"type": "quantitative", | |
"axis": { | |
"grid": false | |
} | |
} | |
} | |
}, | |
{ | |
"mark": "line", | |
"encoding": { | |
"x": { | |
"timeUnit": "month", | |
"field": "date", | |
"type": "ordinal" | |
}, | |
"y": { | |
"aggregate": "mean", | |
"field": "temp_max", | |
"type": "quantitative", | |
"axis": { | |
"grid": false | |
}, | |
"scale": {"zero": false} | |
}, | |
"color": {"value": "firebrick"} | |
} | |
} | |
], | |
"resolve": {"scale": {"y": "independent"}}}, | |
{ | |
"mark": "point", | |
"encoding": { | |
"x": { | |
"field": "temp_min", | |
"type": "quantitative", | |
"bin": true | |
}, | |
"y": { | |
"field": "temp_max", | |
"type": "quantitative", | |
"bin": true | |
}, | |
"size": { | |
"aggregate": "count", | |
"type": "quantitative" | |
} | |
} | |
} | |
]}, | |
{"hconcat": [ | |
{"layer": [ | |
{ | |
"mark": "bar", | |
"encoding": { | |
"x": { | |
"timeUnit": "month", | |
"field": "date", | |
"type": "ordinal" | |
}, | |
"y": { | |
"aggregate": "mean", | |
"field": "precipitation", | |
"type": "quantitative", | |
"axis": { | |
"grid": false | |
} | |
} | |
} | |
}, | |
{ | |
"mark": "line", | |
"encoding": { | |
"x": { | |
"timeUnit": "month", | |
"field": "date", | |
"type": "ordinal" | |
}, | |
"y": { | |
"aggregate": "mean", | |
"field": "temp_max", | |
"type": "quantitative", | |
"axis": { | |
"grid": false | |
}, | |
"scale": {"zero": false} | |
}, | |
"color": {"value": "firebrick"} | |
} | |
} | |
], | |
"resolve": {"scale": {"y": "independent"}}}, | |
{ | |
"mark": "point", | |
"encoding": { | |
"x": { | |
"field": "temp_min", | |
"type": "quantitative", | |
"bin": true | |
}, | |
"y": { | |
"field": "temp_max", | |
"type": "quantitative", | |
"bin": true | |
}, | |
"size": { | |
"aggregate": "count", | |
"type": "quantitative" | |
} | |
} | |
} | |
]}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment