Public
Edited
Aug 4, 2023
Insert cell
Insert cell
data = [
{ x: 1, y: 14 },
{ x: 4, y: 12 },
{ x: 2, y: 10 },
{ x: 6, y: 9 },
{ x: 5, y: 8 },
{ x: 6, y: 6 },
{ x: 9, y: 4 },
{ x: 8, y: 3 },
{ x: 11, y: 3 },
{ x: 12, y: 1 }
]
Insert cell
Plot.plot({
marks: [
Plot.dot(data, { x: "x", y: "y", fill: "black" }),
Plot.text(data, {
x: "x",
y: "y",
fontSize: 13,
fill: "red",
dy: 11,
text: (d) => `(${d.x},${d.y})`
}),
Plot.linearRegressionY(data, { x: "x", y: "y" })
],
grid: true
})
Insert cell
r2 = d3.regressionLinear()(data.map((d) => [d.x, d.y]))
Insert cell
d3 = require("d3-regression@1")
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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