Last active
October 10, 2019 21:15
-
-
Save harishtella/c2f866c443d240c65141f1cecb2856d5 to your computer and use it in GitHub Desktop.
Vega-lite: comparing heatmap and table-bubble-plot
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/v4.json", | |
"data": {"url": "data/cars.json"}, | |
"transform": [ | |
{ | |
"aggregate": [{"op": "count", "as": "num_cars"}], | |
"groupby": ["Origin", "Cylinders"] | |
} | |
], | |
"resolve": { | |
"legend": { | |
"color": "independent", | |
"size": "independent" | |
} | |
}, | |
"vconcat": [ | |
{ | |
"layer": [ | |
{ | |
"mark": { | |
"type": "rect", | |
"tooltip": true | |
}, | |
"encoding": { | |
"y": {"field": "Origin", "type": "nominal"}, | |
"x": {"field": "Cylinders", "type": "ordinal"}, | |
"color": {"field": "num_cars", "type": "quantitative"} | |
} | |
}, | |
{ | |
"mark": "text", | |
"encoding": { | |
"y": {"field": "Origin", "type": "nominal"}, | |
"x": {"field": "Cylinders", "type": "ordinal"}, | |
"text": {"field": "num_cars", "type": "quantitative"}, | |
"color": { | |
"condition": {"test": "datum['num_cars'] < 40", "value": "black"}, | |
"value": "white" | |
} | |
} | |
} | |
] | |
}, | |
{ | |
"mark": { | |
"type": "circle", | |
"tooltip": true | |
}, | |
"encoding": { | |
"y": { | |
"field": "Origin", | |
"type": "nominal" | |
}, | |
"x": { | |
"field": "Cylinders", | |
"type": "ordinal" | |
}, | |
"size": { | |
"type": "quantitative", | |
"field": "num_cars" | |
}, | |
"opacity": { | |
"value": 1 | |
} | |
} | |
} | |
] | |
} |
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/v4.json", | |
"data": {"url": "data/cars.json"}, | |
"resolve": { | |
"legend": { | |
"color": "independent", | |
"size": "independent" | |
} | |
}, | |
"vconcat": [ | |
{ | |
"mark": { | |
"type": "rect", | |
"tooltip": true | |
}, | |
"encoding": { | |
"y": {"field": "Origin", "type": "nominal"}, | |
"x": {"field": "Cylinders", "type": "ordinal"}, | |
"color": {"aggregate": "count", "type": "quantitative"} | |
} | |
}, | |
{ | |
"mark": { | |
"type": "circle", | |
"tooltip": true | |
}, | |
"encoding": { | |
"y": { | |
"field": "Origin", | |
"type": "nominal" | |
}, | |
"x": { | |
"field": "Cylinders", | |
"type": "ordinal" | |
}, | |
"size": { | |
"type": "quantitative", | |
"aggregate": "count" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment