Public
Edited
Jun 14, 2023
Insert cell
Insert cell
Plot.plot({
x: {axis: null, _padding: 0.1, _inset: 6},
y: {tickFormat: "s", grid: true},
fx: {_inset: 90, _round: 10, _align: 0, _padding: 0, label: null, _tickRotate: 90, tickSize: 5},
color: {scheme: "spectral", legend: true},
marks: [
Plot.barY(data, {
x: "key",
y: "population",
fill: "key",
fx: "state",
_padding: 10.5,
// sort: {x: "-y"}, // null, color: null},
// sort: {x: null, color: "y"},
sort: {x: null, color: null, fx: {value: "y", reverse: true, reduce: "sum"}}
}),
Plot.ruleY([0])
]
})
Insert cell
Plot.plot({
x: {axis: null, _padding: 0.1, inset: 2},
y: {tickFormat: "s", grid: true},
fx: {_inset: 90, _round: 10, _align: 0, padding: 0, label: null, _tickRotate: 90, tickSize: 5},
color: {scheme: "spectral", legend: true},
marks: [
Plot.barY(data, {
x: "key",
y: "population",
fill: "key",
fx: "state",
_padding: 10.5,
// sort: {x: "-y"}, // null, color: null},
// sort: {x: null, color: "y"},
sort: {x: null, color: null, fx: {value: "y", reverse: true, reduce: "sum"}}
}),
Plot.ruleY([0])
]
})
Insert cell
Plot.plot({
color: {scheme: "spectral", legend: true},
x: {
type: "band",
tickFormat: d => d.toLocaleString("en", {month: "narrow"}),
label: null,
},
y: {tickFormat: "s", grid: true},
marks: [
Plot.barY(data, {
x: "state",
y: "population",
fill: "key",
sort: {x: null, color: null},
//sort: {x: null, color: null}
}),
Plot.ruleY([0])
]
})
Insert cell
Plot.barY(alphabet, {x: "letter", y: "frequency", stroke: "red", fill: "blue"}).plot()
Insert cell
Plot.barY(alphabet, {x: "letter", y: "frequency"})
Insert cell
data = FileAttachment("population-state-age.csv").csv({typed: true})
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