Skip to content

Instantly share code, notes, and snippets.

@harishtella
Last active October 11, 2019 22:49
Show Gist options
  • Save harishtella/8179a6b5bf2840a7d8a236f667456b83 to your computer and use it in GitHub Desktop.
Save harishtella/8179a6b5bf2840a7d8a236f667456b83 to your computer and use it in GitHub Desktop.
Vega-lite: comparing box-plot and strip-plot
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"height": {"step": 30},
"width": 300,
"description": "Shows the relationship between horsepower and the numbver of cylinders using tick marks.",
"data": {"url": "data/cars.json"},
"mark": {
"type": "boxplot",
"extent": "min-max"
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative",
"axis": {"grid": true}},
"y": {"field": "Cylinders", "type": "ordinal"},
"color": {"aggregate": "count",
"type": "quantitative"}
}
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"url": "data/cars.json"
},
"vconcat": [
{
"mark": {
"type": "boxplot",
"extent": "min-max"
},
"encoding": {
"x": {
"field": "Horsepower",
"type": "quantitative",
"axis": {
"grid": true
}
},
"y": {
"field": "Cylinders",
"type": "ordinal"
},
"color": {
"aggregate": "count",
"type": "quantitative"
}
}
},
{
"layer": [
{
"mark": {
"type": "tick",
"tooltip": true
},
"encoding": {
"x": {
"field": "Horsepower",
"type": "quantitative",
"axis": {
"grid": false
}
},
"y": {
"field": "Cylinders",
"type": "ordinal"
}
}
},
{
"mark": {
"type": "rule"
},
"encoding": {
"x": {
"field": "Horsepower",
"aggregate": "min",
"type": "quantitative",
"axis": {
"grid": false
}
},
"x2": {
"field": "Horsepower",
"aggregate": "max"
},
"y": {
"field": "Cylinders",
"type": "ordinal"
},
"strokeWidth": {
"value": 0.3
}
}
}
]
}
]
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/cars.json"},
"vconcat": [
{
"mark": {
"type": "boxplot",
"extent": "min-max"
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative",
"axis": {"grid": true}},
"y": {"field": "Cylinders", "type": "ordinal"},
"color": {"aggregate": "count",
"type": "quantitative"}
}
},
{
"mark": {
"type": "tick",
"tooltip": true
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative",
"axis": {"grid": false}},
"y": {"field": "Cylinders", "type": "ordinal"}
}
}]
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Shows the relationship between horsepower and the numbver of cylinders using tick marks.",
"data": {"url": "data/cars.json"},
"spacing": 30,
"bounds": "flush",
"hconcat": [
{
"mark": {
"type": "tick",
"tooltip": true
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative",
"axis": {"grid": false}},
"y": {"field": "Cylinders", "type": "ordinal"}
}
},
{
"mark": {
"type": "bar",
"tooltip": true
},
"width": 50,
"encoding": {
"y": {
"field": "Cylinders",
"type": "ordinal",
"axis": null
},
"x": {
"aggregate": "count",
"type": "quantitative",
"title": "count"
}
}
}
]
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"height": {"step": 30},
"width": 300,
"description": "Shows the relationship between horsepower and the numbver of cylinders using tick marks.",
"data": {"url": "data/cars.json"},
"mark": {
"type": "tick",
"tooltip": true
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative",
"axis": {"grid": false}},
"y": {"field": "Cylinders", "type": "ordinal"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment