Public
Edited
Apr 23, 2023
Insert cell
Insert cell
crimea = FileAttachment("EV export top15-refined.csv").csv()

Insert cell
Plot.plot({
y: {
grid: true
},
color: {
legend: true
},
marks: [
Plot.lineY(crimea, {x: "year", y: "car", stroke: "destination", marker: "circle"}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true
},
marks: [
Plot.areaY(crimea, {x: "year", y2: "car", fill: "destinatio", mixBlendMode: "multiply"}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true
},
marks: [
Plot.areaY(crimea, {x: "date", y: "car", fill: "destination"}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
x: {
type: "band",
tickFormat: d => d.toLocaleString("en", {month: "narrow"}),
label: null
},
marks: [
Plot.barY(crimea, {x: "date", y: "deaths", fill: "cause"}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
unemployment = FileAttachment("EV export top15-refined.csv").csv({typed: true})
Insert cell
Insert cell
stacked = Plot.plot({
y: {
grid: true,
label: "↑ Unemployed (thousands)"
},
marks: [
Plot.areaY(unemployment, Plot.stackY({x: "year", y: "car", fill: "destination"})),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
label: "↑ Unemployed (thousands)"
},
marks: [
Plot.areaY(unemployment, Plot.stackY({offset: "center", x: "date", y: "unemployed", fill: "industry"}))
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
label: "↑ Unemployed (thousands)"
},
marks: [
Plot.areaY(unemployment, Plot.stackY({offset: "wiggle", x: "year", y: "car", fill: "destination"}))
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
label: "EV export - top 15 destinations in 2022"
},
marks: [
Plot.areaY(unemployment, Plot.stackY({
x: "year",
y: "car",
curve: "bump-x",
fill: "destination",
order: "value",
offset: "center"
})),
Plot.ruleY([0])
]
})
// options: [
// "linear",
// "step",
// "step-after",
// "step-before",
// "basis",
// "cardinal",
// "catmull-rom",
// "monotone-x",
// "bump-x",
// "natural"
// ],
Insert cell
Insert cell
riaa = FileAttachment("riaa-us-revenue.csv").csv({typed: true})
Insert cell
{
const xy = {x: "year", y: "car", z: "format", order: "appearance", reverse: true};
return Plot.plot({
y: {
grid: true,
label: "↑ Annual revenue (billions, adj.)",
transform: d => d / 1000
},
marks: [
Plot.areaY(riaa, Plot.stackY({...xy, fill: "group", title: d => `${d.format}\n${d.group}`})),
Plot.lineY(riaa, Plot.stackY1({...xy, stroke: "white", strokeWidth: 1})),
Plot.ruleY([0])
],
color: {legend: true}
});
}
Insert cell
Insert cell
{
const xy = {x: "year", y: "revenue", z: "format", order: "appearance", offset: "expand", reverse: true};
return Plot.plot({
y: {
grid: true,
label: "↑ Revenue (%)",
percent: true
},
marks: [
Plot.areaY(riaa, Plot.stackY({...xy, fill: "group", title: d => `${d.format}\n${d.group}`})),
Plot.lineY(riaa, Plot.stackY2({...xy, stroke: "white", strokeWidth: 1})),
Plot.ruleY([0, 1])
]
});
}
Insert cell
Insert cell
congress = FileAttachment("us-congress-members.csv").csv({typed: true})
Insert cell
Plot.plot({
height: 300,
x: {
label: "Age →",
nice: true
},
y: {
grid: true,
label: "← Women · Men →",
labelAnchor: "center",
tickFormat: Math.abs
},
marks: [
Plot.dot(congress, Plot.stackY2({
x: d => 2021 - d.birth,
y: d => d.gender === "M" ? 1 : d.gender === "F" ? -1 : 0,
fill: "gender"
})),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
height: 280,
x: {
percent: true
},
facet: {
data: congress,
y: d => Math.floor((2021 - d.birth) / 10) * 10
},
marks: [
Plot.barX(congress, Plot.stackX(Plot.groupZ({x: "proportion-facet"}, {fill: "gender"}))),
Plot.text(congress, Plot.stackX(Plot.groupZ({x: "proportion-facet", text: "first"}, {z: "gender", text: d => d.gender === "F" ? "Women" : d.gender === "M" ? "Men" : null}))),
Plot.ruleX([0, 1])
]
})
Insert cell
Insert cell
iowa = FileAttachment("EV export top15-refined.csv").csv({typed: true})
Insert cell
Insert cell
energy = Plot.plot({
y: {
grid: true,
label: "↑ Net generation (million MWh)",
transform: d => d / 1000
},
marks: [
Plot.areaY(iowa, Plot.stackY({x: "year", y: "car", fill: "destination",
curve: "",
order
})),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
crimea.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
EV export top15-refined.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more