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 },
marginTop: 40,
width: 650,
height: 400,
x: {
tickFormat: d3.format("d") // removes commas by using integer format
},
color: {scheme: "YlGn", legend: true, domain: ["Bottom 80%", "Top 20-5%", "Top 5-1%", "Top 1%"]},
marks: [
Plot.text([{}], {
text: () => "Distribution of Taxable Wealth in Massachusetts 1820 - 1910 (10 year increments)",
frameAnchor: "top",
anchor: "middle",
dy: -20,
fontSize: 13,
fontWeight: "bold"
}),
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
workbook1 = FileAttachment("WID_Data_07052025-175552@5.xlsx").xlsx()
Insert cell
workbook1.sheetNames
Insert cell
data3 = workbook1.sheet(0, {
headers: false,
// range: "A1:J10"
})
Insert cell
data3
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
workbook.sheetNames
Insert cell
data2 = workbook.sheet(0, {
headers: true
})
Insert cell
Plot.plot({
//y: { reverse: true },
marginTop: 40,
width: 600,
height: 400,
x: {
tickFormat: d3.format("d") // removes commas by using integer format
},
color: {scheme: "YlGn", legend: true},
marks: [
Plot.text([{}], {
text: () => "Distribution of Wealth in United States 2010 - 2023 (1 Year Increments)",
frameAnchor: "top",
anchor: "middle",
dy: -20,
fontSize: 13,
fontWeight: "bold"
}),
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