Skip to content

Instantly share code, notes, and snippets.

@crispamares
Created February 8, 2022 18:18
Show Gist options
  • Save crispamares/bf076259c7783055a086ebabc8e2b049 to your computer and use it in GitHub Desktop.
Save crispamares/bf076259c7783055a086ebabc8e2b049 to your computer and use it in GitHub Desktop.
Render 200K scatterplot with vega
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic scatter plot example depicting automobile statistics.",
"width": 800,
"height": 600,
"padding": 5,
"data": [
{
"name": "source",
"url": "data/flights-200k.json",
"transform": [
{
"type": "filter",
"expr": "datum['delay'] != null && datum['distance'] != null && datum['time'] != null"
}
]
}
],
"scales": [
{
"name": "x",
"type": "linear",
"round": true,
"nice": true,
"zero": true,
"domain": {"data": "source", "field": "delay"},
"range": "width"
},
{
"name": "y",
"type": "linear",
"round": true,
"nice": true,
"zero": true,
"domain": {"data": "source", "field": "distance"},
"range": "height"
},
{
"name": "size",
"type": "linear",
"round": true,
"nice": false,
"zero": true,
"domain": {"data": "source", "field": "time"},
"range": [4,361]
}
],
"axes": [
{
"scale": "x",
"grid": true,
"domain": false,
"orient": "bottom",
"tickCount": 5,
"title": "delay"
},
{
"scale": "y",
"grid": true,
"domain": false,
"orient": "left",
"titlePadding": 5,
"title": "distance"
}
],
"legends": [
{
"size": "size",
"title": "time",
"format": "s",
"symbolStrokeColor": "#4682b4",
"symbolStrokeWidth": 20,
"symbolOpacity": 0.5,
"symbolType": "circle"
}
],
"marks": [
{
"name": "marks",
"type": "symbol",
"from": {"data": "source"},
"encode": {
"update": {
"x": {"scale": "x", "field": "delay"},
"y": {"scale": "y", "field": "distance"},
"size": {"scale": "size", "field": "time"},
"shape": {"value": "circle"},
"strokeWidth": {"value": 2},
"opacity": {"value": 0.5},
"stroke": {"value": "#4682b4"},
"fill": {"value": "transparent"}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment