Public
Edited
Mar 13, 2023
Insert cell
Insert cell
data = {
const url = await FileAttachment("Relationships Raw Data Public - Sheet1@2.csv").url()

return d3.csv(url, d3.autoType)
}
Insert cell
fields = data.columns.filter(d => !d.endsWith(')')).filter(d => d !== '')
Insert cell
Plot.plot({
width,
marginLeft: 120,
marginBottom: 120,
color: {
type: "diverging",
scheme: "rdylbu",
nice: true,
// pivot: 0,
legend: true,
label: "correlation"
},
y: {
label: null,
},
x: {
tickRotate: -90,
axis: 'bottom',
label: null,
},
marks: [
Plot.cell(d3.cross(fields, fields), {
fill: ([a, b]) =>
a !== b
? corr(Plot.valueof(data, a), Plot.valueof(data, b))
: 'white',
}),

Plot.text(d3.cross(fields, fields), {
text: ([a, b]) =>
a !== b && Math.abs(corr(Plot.valueof(data, a), Plot.valueof(data, b)).toFixed(2)) > 0.8
? corr(Plot.valueof(data, a), Plot.valueof(data, b)).toFixed(2)
: '',
fill: "white",
stroke: "rgba(0,0,0,.3)"
})
]
})
Insert cell
Insert cell
import { corr } from '@fil/correlation-heatmap'
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