Public
Edited
Aug 24, 2023
8 forks
Importers
19 stars
Insert cell
Insert cell
Insert cell
Plot.plot({
height: 420,
axis: null,
color: {
type: "diverging-log", // diverging-log scales pivot at 1 by default
scheme: "piyg"
},
marks: [
Plot.cell(states, {x: "x", y: "y", fill: change}),
Plot.text(states, {x: "x", y: "y", text: "key", dy: -2}), // state abbr
Plot.text(states, {x: "x", y: "y", text: formatChange, dy: 10, fillOpacity: 0.6})
]
})
Insert cell
Insert cell
grid = FileAttachment("grid.csv").csv({ typed: true })
.then((states) => new Map(states.map((state) => [state.name, state])))
Insert cell
population = FileAttachment("population.csv").csv({typed: true})
Insert cell
states = population
.filter((d) => grid.has(d.State))
.map((d) => ({ ...d, ...grid.get(d.State) }))
Insert cell
change = d => d["2019"] / d["2010"]
Insert cell
formatChange = ((f) => (d) => f(change(d) - 1))(d3.format("+.0%"))
Insert cell
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