Public
Edited
Jul 30, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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
.map((d) => ({
year: d.Year,
watershed: d.Watershed,
stemLength: d.StemLength,
leafMass: d.LeafDryMass,
stemMass: d.StemDryMass,
leafArea: d.CorrectedLeafArea
}))
.filter((d) => d.year == 2003)
Insert cell
Insert cell
Insert cell
Insert cell
maples2003
X
leafArea
Y
Color
watershed
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",
tip: true
}),
Plot.linearRegressionY(maples2003, {
x: "stemLength",
y: "stemMass",
stroke: "watershed"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
import { PlotMatrix } with { maples2003 as data } from "@observablehq/autoplot-matrix"
Insert cell
PlotMatrix(maples2003)
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
import { scale, asMatrix } from "@chrispahm/hierarchical-clustering"
Insert cell
import { viewof scores } with {
maples2003Scaled as food_scaled,
maples2003 as food
} from "@chrispahm/principal-component-analysis"
Insert cell
import { viewof loadings } with { maples2003Scaled as food_scaled } from "@chrispahm/principal-component-analysis"
Insert cell
Insert cell
maples2003Scaled = scale(maples2003.map(({ year, watershed, ...rest }) => rest))
Insert cell
Insert cell
maples20003PCA = new ML.PCA(maples2003Scaled.map(Object.values))
Insert cell
Insert cell
Insert cell
cumulativeVarience = maples20003PCA.getCumulativeVariance()
Insert cell
Insert cell
viewof loadings
Insert cell
Insert cell
viewof scores
Insert cell
scoresCombined = scores.map((d, i) => ({
...d,
year: maples2003[i].year,
watershed: maples2003[i].watershed
}))
Insert cell
scalingFactor = 6
Insert cell
Plot.plot({
marks: [
Plot.dot(scoresCombined, {
x: "PC1",
y: "PC2",
fill: "watershed",
r: 4,
opacity: 0.85,
stroke: "black",
strokeOpacity: 0.8,
tip: true
}),
Plot.arrow(loadings, {
x1: 0,
x2: (d) => d.PC1 * scalingFactor,
y1: 0,
y2: (d) => d.PC2 * scalingFactor
}),
Plot.text(loadings, {
x: (d) => d.PC1 * scalingFactor,
y: (d) => d.PC2 * scalingFactor,
text: "Variable",
dy: -5,
dx: 30,
fill: "black",
stroke: "white"
})
],
color: { legend: true }
})
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