Skip to content

Instantly share code, notes, and snippets.

@keckelt
Created November 30, 2020 09:55
Show Gist options
  • Save keckelt/f8b2d0fd57cc9539ed16ce7f8bf64d08 to your computer and use it in GitHub Desktop.
Save keckelt/f8b2d0fd57cc9539ed16ce7f8bf64d08 to your computer and use it in GitHub Desktop.
Sentiment Emojy Isotype Plot
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"config": {"view": {"stroke": ""}},
"width": 800,
"height": 200,
"data": {
"values": [
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "cattle"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"},
{"country": "United States", "animal": "sheep"}
]
},
"transform": [
{
"calculate": "{'cattle': '💩', 'pigs': '🐖', 'sheep': '😃'}[datum.animal]",
"as": "emoji"
},
{"window": [{"op": "rank", "as": "rank"}], "groupby": ["country", "animal"]}
],
"mark": {"type": "text", "baseline": "middle"},
"encoding": {
"x": {"field": "rank", "type": "ordinal", "axis": null},
"y": {"field": "animal", "type": "nominal", "axis": null, "sort": null},
"row": {"field": "country", "header": {"title": ""}},
"text": {"field": "emoji", "type": "nominal"},
"size": {"value": 50}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment