Published
Edited
Oct 29, 2021
1 star
Insert cell
Insert cell
Insert cell
Plot.plot({
y: {
grid: true
},
marks: [
Plot.line(data, { x: "time", y: "value", stroke: "gray" }),
Plot.ruleY([d3.mean(data.map((d) => d.value))], {
stroke: "gray"
}),
Plot.ruleY([d3.mean(regularlySampled.map((d) => d.value))], {
stroke: "blue"
}),
Plot.dot(regularlySampled, { x: "time", y: "value", fill: "blue" }),
Plot.ruleY([d3.mean(irregularlySampled.map((d) => d.value))], {
stroke: "firebrick"
}),
Plot.dot(irregularlySampled, { x: "time", y: "value", fill: "firebrick" })
]
})
Insert cell
data = aapl.map((d, i) => ({ time: i, value: d.Close }))
Insert cell
regularlySampled = data.filter((d, i) => i % Math.round(1 / sampling) == 0)
Insert cell
irregularlySampled = data.filter((d, i) => Math.random() <= 1 * sampling)
Insert cell
aapl = FileAttachment("aapl.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