Published
Edited
Jun 18, 2021
Insert cell
# ACLED insight3 viz
Insert cell
violent_20vs21=FileAttachment("2020vs2021.csv").csv({typed: true})
Insert cell
violent_18_21=FileAttachment("2018_2021.csv").csv({typed: true})
Insert cell
Plot.plot({
width: width,
height: 400,
padding: 0,
y: {label:"Sub_event_type", domain: ["all" ,"Sexual violence", "Attack","Abduction/forced disappearance","Air/drone strike","Suicide bomb","Shelling/artillery/missile attack","Remote explosive/landmine/IED","Grenade","Armed clash","Government regains territory","Non-state actor overtakes territory"]},
color: {scheme: "BuYlRd", type: "pow", exponent: 1 , domain: [0, 2]},
marks: [
Plot.cell(
violent_20vs21.filter(d=>d.rate<200), {
x: "country",
y: "sub_event_type",
fill: "rate",
inset: 2}
),
Plot.text(
violent_20vs21.filter(d=>d.rate!="500"),
{
x: "country",
y: "sub_event_type",
text: d => {return d.rate==300?".":d3.format(".0%")(d.rate)},
fill: "#000000",
fontWeight: "bold",
}
)
]
})
Insert cell
Plot.plot({
width: width,
height: 400,
padding: 0,
y: {label:"Sub_event_type" , domain: ["all" ,"Sexual violence", "Attack","Abduction/forced disappearance","Air/drone strike","Suicide bomb","Shelling/artillery/missile attack","Remote explosive/landmine/IED","Grenade","Armed clash","Government regains territory","Non-state actor overtakes territory"]},
color: {scheme: "BuYlRd", type: "pow", exponent: 1 /2, domain: [0, 5]},
marks: [
Plot.cell(
violent_18_21.filter(d=>d.rate<200), {
x: "country",
y: "sub_event_type",
fill:"rate",
inset: 2}
),
Plot.text(
violent_18_21.filter(d=>d.rate<400),
{
x: "country",
y: "sub_event_type",
text: d => d.rate==300?".":d3.format(".0%")(d.rate),
fill: "#000000",
fontWeight: "bold",
}
)
]
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more