Skip to content

Instantly share code, notes, and snippets.

@AliciaSchep
Created November 19, 2017 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliciaSchep/68755433c041736e5dc6182c9990c6ab to your computer and use it in GitHub Desktop.
Save AliciaSchep/68755433c041736e5dc6182c9990c6ab to your computer and use it in GitHub Desktop.
vegalite hconcat plus vconcat plus layer
{
"$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