Published
Edited
Apr 14, 2021
15 stars
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("boston_correlation_matrix.csv").csv({ typed: true })
Insert cell
Insert cell
niceNames = new Map([
["crim", "Crime per capita"],
["zn", "Residential land zoned for large lots"],
["indus", "Non-retail business acres"],
["chas", "Charles River adjacent"],
["nox", "Nitrogen oxides concentration"],
["rm", "Rooms per dwelling"],
["age", "Units built prior to 1940"],
["dis", "Mean distance to employment centres"],
["rad", "Accessibility to radial highways"],
["tax", "Property-tax rate"],
["ptratio", "Pupil-teacher ratio"],
["black", "Proportion of Black residents"],
["lstat", "Lower status of population"],
["medv", "Median value of homes"]
])
Insert cell
Insert cell
radius = 260
Insert cell
Insert cell
labelPadFactor = 1.03
Insert cell
Insert cell
height = width * 0.75
Insert cell
Insert cell
// size of color legend
marginTop = 50
Insert cell
// more scales available here https://github.com/d3/d3-scale-chromatic
color = d3.scaleSequential([-1, 1], d3.interpolateRdBu)
Insert cell
stroke = value => 3 * Math.abs(value)
Insert cell
nodes = data.map(d => d.id)
Insert cell
getPoint = id => {
const i = nodes.indexOf(id);
return [radius * Math.cos(angle(i)), radius * Math.sin(angle(i))];
}
Insert cell
angle = d3.scaleLinear([0, nodes.length], [0, Math.PI * 2])
Insert cell
d3 = require("d3@6")
Insert cell
import {legend} from "@d3/color-legend"
Insert cell
Insert cell
Insert cell
import { cor } from "@borisvish/correlation-filtering"
Insert cell
Insert cell
d3
.rollups(
cor,
arr => Object.fromEntries(arr.map(({ key2, cor }) => [key2, cor])),
d => d.key1
)
.map(([id, obj]) => ({ id, ...obj }))
Insert cell
Insert cell
import { datasets } from "@tmcw/rdatasets"
Insert cell
datasets.Boston.doc
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