Public
Edited
Jul 28, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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
maples2003 = maples.filter(m=>m.Year == 2003).map(m=>({
year: m.Year,
watershed: m.Watershed,
stemLength: m.StemLength,
leafMass: m.LeafDryMass,
stemMass: m.StemDryMass,
leafArea: m.CorrectedLeafArea
}))
Insert cell
Insert cell
Insert cell
Insert cell
maples2003
X
leafMass
Y
Color
watershed
Size
Facet X
watershed
Facet Y
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: (d) => d.stemMass,
y: (d) => d.stemLength,
fill: (d) => d.watershed
}),
Plot.linearRegressionY(maples2003, {
x: (d) => d.stemMass,
y: (d) => d.stemLength,
fill: (d) => d.watershed
}),
Plot.linearRegressionX(maples2003, {
x: (d) => d.stemMass,
y: (d) => d.stemLength,
fill: (d) => d.watershed,
opacity: 0.7,
stroke: d => d.watershed,
strokeDasharray: '1 3',
fill: 'none'
}),
],
color: { legend: true },
x: { label: "stemMass (g)" },
y: { label: "stemLength (mm)" }
})
Insert cell
Insert cell
Insert cell
Insert cell
import {PlotMatrix} with {maples2003 as data} from "@observablehq/autoplot-matrix"
Insert cell
PlotMatrix()
Insert cell
Insert cell
Insert cell
Insert cell

import {scale} from "@chrispahm/hierarchical-clustering";
Insert cell
Insert cell
maples2003Array = maples2003Scaled.map(Object.values)
Insert cell
maples2003PCA = new ML.PCA(maples2003Array)
Insert cell
maples2003PCA.getExplainedVariance()
Insert cell
maples2003PCA.getCumulativeVariance()
Insert cell
// Import viewof loadings from the notebook
import { viewof loadings } with { maples2003Scaled as food_scaled } from "@chrispahm/principal-component-analysis"
Insert cell
viewof loadings
Insert cell
import { viewof scores } with { maples2003Scaled as food_scaled, maples2003 as food} from "@chrispahm/principal-component-analysis"
Insert cell
viewof scores
Insert cell
scoresCombined = scores.map((d,i)=> ({
...d,
watershed: maples2003[i].watershed,
}))
Insert cell
chart = Plot.plot({
marks: [
Plot.dot(scoresCombined, {
x: 'PC1',
y: 'PC2',
fill: 'watershed'
}),
Plot.arrow(loadings, {
x1: 0,
x2: d => d.PC1 * 4,
y1: 0,
y2: d => d.PC2 * 4,
}),
Plot.text(loadings, {
x: d => d.PC1 * 4.8,
y: d => d.PC2 * 4.4,
text: 'Variable',
fill: 'black',
stroke: 'white',
strokeWidth: 1
})
],
color:{legend: true}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ML = require("https://www.lactame.com/lib/ml/6.0.0/ml.min.js")
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