Public
Edited
Jan 30, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
economist_plot = Plot.plot({
// inset: 2,
width: 1000,
height: 1000 * 0.618,
caption:
"*Where rental costs make up 30% of annual wage. Based on median studio rental prices, July 2023. Sources: Bureau of Labor Statistics; Zumper.\nCopyright 2023 The Economist.\nRecreated by @kpivert@fosstodon.org",
y: {
domain: [0, 150000],
axis: "right",
ticks: 4,
tickFormat: "$,.0",
tickSize: 0
},
x: { axis: null },
margin: 80,
color: { legend: true },
marks: [
Plot.ruleY([0, 50000, 100000, 150000], { stroke: "#cccccc" }),
Plot.dot(data_updated, {
x: "index",
y: "affordable_rent_wage",
fill: "#e2130c",
r: 4
// tip: true
}),
Plot.dot(data_updated, {
x: "index",
y: "median_wage",
fill: "#1c2b73",
r: 4
// tip: true
}),
Plot.ruleX(data_updated, {
x: "index",
y1: "affordable_rent_wage",
y2: "median_wage",
tip: true,
title: (d) =>
`${
d.city
}\nThe affordable rent wage is \$${d.affordable_rent_wage.toLocaleString()},\nwhich is \$${Math.abs(
d.diff
).toLocaleString()} ${d.more_less} than the median wage`
})
]
})
Insert cell
Insert cell
data_updated = data.map((d, index) => ({
...d,
median_wage: d.affordable_rent_wage - d.diff,
more_less: d.diff > 0 ? "more" : "less",
index
}))
Insert cell
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