Public
Edited
Jun 14, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
label: "Frequency (%)",
transform: (d) => d * 100
},
marks: [
Plot.barY(alphabet, {
x: "letter",
y: "frequency",
sort: { x: "y", reverse: true }
}),
Plot.text(alphabet, {
x: "letter",
y: "frequency",
text: (d) => (d.frequency * 100).toFixed(1),
dy: -4
}),
Plot.ruleY([0])
]
})
Insert cell
Plot.plot({
x: {
grid: true,
label: "Frequency (%)",
transform: (d) => d * 100
},
marks: [
Plot.barX(alphabet, {
y: "letter",
x: "frequency",
sort: { y: "x", reverse: true }
}),
Plot.text(alphabet, {
y: "letter",
x: "frequency",
text: (d) => (d.frequency * 100).toFixed(1),
dx: 10
}),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
x: {
tickFormat: (d) => (d === null ? "N/A" : d)
},
y: {
grid: true
},
facet: {
data: penguins,
x: "species"
},
marks: [
Plot.barY(penguins, Plot.groupX({ y: "count" }, { x: "sex" })),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true
},
marks: [
Plot.barY(
penguins,
Plot.groupX({ y: "count" }, { x: "species", fill: "sex" })
),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {
grid: true,
tickFormat: (value, index, values) => Math.abs(value)
},
marks: [
Plot.barY(
penguins.filter((d) => d.sex !== null),
Plot.groupX(
{ y: (d) => (d[0].sex === "MALE" ? d.length : -d.length) },
{ x: "species", fill: "sex" }
)
),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Insert cell
weather[0].date.getFullYear()
Insert cell
weather2012 = weather.filter((d) => d.date.getFullYear() === 2012)
Insert cell
weather2013 = weather.filter((d) => d.date.getFullYear() === 2013)
Insert cell
weather2014 = weather.filter((d) => d.date.getFullYear() === 2014)
Insert cell
weather2015 = weather.filter((d) => d.date.getFullYear() === 2015)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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