Plot.plot({
width,
marginLeft: 120,
marginBottom: 120,
color: {
type: "diverging",
scheme: "rdylbu",
nice: true,
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)"
})
]
})