Public
Edited
May 5, 2023
Insert cell
Insert cell
data = FileAttachment("data.csv").csv({ typed: true })
Insert cell
data_year_filter = data.filter((d) => d.year >= 1900)
Insert cell
data_global_average = d3.rollup(
data_year_filter,
(v) => d3.mean(v, (d) => d.v2xca_academ),
(d) => d.year
)
Insert cell
data_global_average_array = Array.from(data_global_average).map((d) => ({
year: d[0],
country_name: "Global average",
v2xca_academ: d[1]
}))
Insert cell
[...new Set(data_year_filter.map((d) => d.country_name))]
Insert cell
data_to_plot = [
...data_year_filter.filter(
(d) =>
d.country_name === "Egypt" ||
d.country_name === "Germany" ||
d.country_name === "Ireland" ||
d.country_name === "Turkey"
),
...data_global_average_array
]
Insert cell
Plot.plot({
color: { legend: true },
y: { grid: true, domain: [0, 1] },
x: { tickFormat: (d) => d.toString(), domain: [1900, 2025] },
marks: [
Plot.ruleY([0]),
Plot.lineY(data_to_plot, {
x: "year",
y: "v2xca_academ",
z: "country_name",
stroke: "country_name"
})
]
})
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