Skip to content

Instantly share code, notes, and snippets.

@keckelt
Last active June 7, 2023 06:13
Show Gist options
  • Save keckelt/9f7840f6007801b0d6953a87ab5c8e3c to your computer and use it in GitHub Desktop.
Save keckelt/9f7840f6007801b0d6953a87ab5c8e3c to your computer and use it in GitHub Desktop.
Ditox Paper - Data Distribution
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"level": "No Hate", "English": 379, "German": 882},
{"level": "Intimidation", "English": 241, "German": 193},
{"level": "Offends or~Discriminates", "English": 780, "German": 354},
{"level": "Promotes~Violence", "English": 83, "German": 55}
]
},
"transform": [{"calculate": "split(datum.level, '~')", "as": "level"}],
"title": "English and German Dataset Distribution",
"repeat": {"layer": ["English", "German"]},
"width": 300,
"height": 180,
"spec": {
"encoding": {},
"layer": [
{
"mark": "bar",
"encoding": {
"y": {
"field": "level",
"type": "nominal",
"title": "Intensities",
"axis": {
"titleAngle": 0,
"titleAlign": "right",
"titleAnchor": "start",
"titleX": -6,
"titleY": 8
},
"sort": null
},
"x": {
"aggregate": "sum",
"field": {"repeat": "layer"},
"type": "quantitative",
"title": "Number of Data Points",
"axis": {"values": [200, 400, 600, 800], "grid": false},
"scale": {"domain": [0, 1000]}
},
"color": {
"datum": {"repeat": "layer"},
"title": "",
"legend": {"orient": "none", "legendX": 245, "legendY": 145},
"scale": {"scheme": "Set2"}
},
"yOffset": {"datum": {"repeat": "layer"}}
}
},
{
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"dx": 3
},
"encoding": {
"y": {
"field": "level",
"type": "nominal",
"title": "Intensities",
"axis": {
"titleAngle": 0,
"titleAlign": "right",
"titleAnchor": "start",
"titleX": -6
},
"sort": null
},
"x": {
"aggregate": "sum",
"field": {"repeat": "layer"},
"type": "quantitative"
},
"color": {
"datum": {"repeat": "layer"},
"title": "",
"legend": {"orient": "none", "legendX": 245, "legendY": 145},
"scale": {"scheme": "Set2"}
},
"yOffset": {"datum": {"repeat": "layer"}},
"text": {
"aggregate": "sum",
"field": {"repeat": "layer"},
"type": "quantitative"
}
}
}
]
},
"config": {"mark": {"invalid": null}, "view": {"strokeWidth": 0}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment