Skip to content

Instantly share code, notes, and snippets.

@declann
Created November 26, 2024 17:25
Show Gist options
  • Save declann/a25d2090d7a6e4df56d4ab93208d3053 to your computer and use it in GitHub Desktop.
Save declann/a25d2090d7a6e4df56d4ab93208d3053 to your computer and use it in GitHub Desktop.
density.json
{
"meta": {
"title": "Density 1D",
"description": "Density plots (`densityY` mark) for over 200,000 flights, created using kernel density estimation. Binning is performned in-database, subsequent smoothing in-browser. The distance density uses a log-scaled domain. To change the amount of smoothing, use the slider to set the kernel bandwidth.\n"
},
"data": {
"flights": {
"file": "data/flights-200k.parquet"
}
},
"params": {
"brush": {
"select": "crossfilter"
},
"bandwidth": 20
},
"vconcat": [
{
"input": "slider",
"label": "Bandwidth (σ)",
"as": "$bandwidth",
"min": 0.1,
"max": 100,
"step": 0.1
},
{
"plot": [
{
"mark": "densityY",
"data": {
"from": "flights"
},
"x": "delay",
"fill": "#888",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"mark": "densityY",
"data": {
"from": "flights",
"filterBy": "$brush"
},
"x": "delay",
"fill": "aqua",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"select": "intervalX",
"as": "$brush"
}
],
"yAxis": null,
"xDomain": "Fixed",
"width": 600,
"marginLeft": 10,
"height": 200
},
{
"plot": [
{
"mark": "densityY",
"data": {
"from": "flights"
},
"x": "distance",
"fill": "#888",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"mark": "densityY",
"data": {
"from": "flights",
"filterBy": "$brush"
},
"x": "distance",
"fill": "aqua",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"select": "intervalX",
"as": "$brush"
}
],
"yAxis": null,
"xScale": "log",
"xDomain": "Fixed",
"width": 600,
"marginLeft": 10,
"height": 200
},
{
"plot": [
{
"mark": "densityY",
"data": {
"from": "flights"
},
"x": "time",
"fill": "#888",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"mark": "densityY",
"data": {
"from": "flights",
"filterBy": "$brush"
},
"x": "time",
"fill": "aqua",
"fillOpacity": 0.5,
"bandwidth": "$bandwidth"
},
{
"select": "intervalX",
"as": "$brush"
}
],
"xDomain": "Fixed",
"xLabel": "Departure Time (hour)",
"yTickFormat": "s",
"yAxis": null,
"width": 600,
"marginLeft": 10,
"height": 200
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment