Plot.plot({
marginLeft: 150,
width: 1500,
height: 400,
color: { scheme: "rdylbu", pivot: 0, legend: true, label: "correlation" },
marks: [
Plot.cell(d3.cross(fields, fields), {
fill: ([a, b]) => corr(Plot.valueof(data, a), Plot.valueof(data, b))
}),
Plot.text(d3.cross(fields, fields), {
text: ([a, b]) =>
corr(Plot.valueof(data, a), Plot.valueof(data, b)).toFixed(2),
fill: "white",
stroke: "rgba(0,0,0,.3)"
})
]
})