Public
Edited
Jul 26, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//file location https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-hbr.157.3&entityid=5c415a399b00430d35d13c31312f1e53
maples = d3.csv('https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-hbr.157.3&entityid=5c415a399b00430d35d13c31312f1e53', d3.autoType)
Insert cell
Insert cell
Insert cell
Insert cell
maples
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
maplesDB = DuckDBClient.of({maples_table: maples})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maples2003
X
leafArea
Y
Color
Size
Facet X
Facet Y
watershed
Mark
Auto
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.dot(maples2003, {x: "stemLength", y: "stemMass", fill: "watershed"})
]
})
Insert cell
ML = require("https://www.lactame.com/lib/ml/6.0.0/ml.min.js")
Insert cell
//The function needs an array of values for X and an array of values for Y
maplesLM = new ML.SimpleLinearRegression(maples2003.map((d) => d.stemLength), maples2003.map((d) => d.stemMass))
//the slope 0.001 is the average change, we expect for each change in stemLength the stemMass increase almost nothing
Insert cell

Plot.plot({
marks: [
Plot.dot(maples2003, {x: "stemLength", y: "stemMass", fill: "watershed"}),
Plot.linearRegressionY(maples2003,{x:"stemLength", y:"stemMass", fill:"watershed"}),
Plot.frame()
],
x:{label: "stem length"},
y:{label: "stem mass"},
color:{legend:true}

})
Insert cell
Insert cell
Insert cell
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