Public
Edited
May 14
Insert cell
Insert cell
data = FileAttachment("Distribution of Taxable Wealth of Male Household Heads in Massachusetts@1.csv").csv({typed: true})
Insert cell
data1 = data.columns.slice(1)
.flatMap((Percent) => data.map(({ Year, [Percent]: Wealth }) => ({ Year, Percent, Wealth })));
Insert cell
Plot.plot({
//y: { reverse: true },
color: {scheme: "YlGn", legend: true, domain: ["Bottom 80%", "Top 20-5%", "Top 5-1%", "Top 1%"]},
marks: [
Plot.barY(data1, {x: "Year", y: "Wealth", fill: "Percent", reverse: true}),
Plot.textY(
data1,
Plot.stackY(
{
x: "Year",
z: "Percent",
y: "Wealth",
text: (d) => (d.Wealth < 5 ? null : d.Wealth),
reverse: true
}
)
),
Plot.ruleY([0])
]
})
Insert cell
workbook = FileAttachment("fixed.xlsx").xlsx()
Insert cell
workbook.sheetNames
Insert cell
data2 = workbook.sheet(0, {
headers: true
})
Insert cell
data2
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
color: {scheme: "YlGn", legend: true},
marks: [
Plot.barY(data2, {x: "Year", y: "Wealth", fill: "Percentile", reverse: true}),
Plot.textY(
data2,
Plot.stackY(
{
x: "Year",
z: "Percentile",
y: "Wealth",
text: (d) => (d.Wealth*100 < 5 ? null : d.Wealth*100),
reverse: true
}
)
),
Plot.ruleY([0])
]
})
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