function summaryDots(data, criteria) {
const subset = data.filter(d => d.criteria === criteria);
const n = 4;
const keys = Array.from(d3.union(demoExposureData.map((d) => d.species)));
const index = new Map(keys.map((key, i) => [key, i]));
const fx = (key) => index.get(key) % n;
const fy = (key) => Math.floor(index.get(key) / n);
const plot = Plot.plot({
title: "Predicted exposures for each species",
subtitle: "A comparison of exposures based on each proposed schedule, shown at both 10 and 15 dB. Note y-axis log scale.",
height: 550,
width: 700,
y: {label: "# exposures", type: "log", insetTop: 10},
x: {label: null, transform: (d) => d + "dB"},
fy: {label: null, padding: 0.05, tickFormat: null},
fx: {padding: 0.05, tickFormat: null},
color: {scheme: "Tableau10", legend: true},
grid: true,
marginLeft: 25,
marginBottom: 40,
marks: [
Plot.frame(),
Plot.dot(
subset, {
x: "attenuation",
y: "exposures",
fx: (d) => fx(d.species),
fy: (d) => fy(d.species),
tip: true,
fill: "sch",
r: 5,
}),
Plot.text(keys, {fx, fy, frameAnchor: "top-left", dx: 6, dy: 6}),
]
});
return plot;
}