function redraw() {
const plt1 = Plot.plot({
width: 400,
aspectRatio: 1.0,
grid: true,
x: { nice: true, domain: bounding.range.x },
y: { nice: true, domain: bounding.range.y },
color: { nice: true, legend: true, scheme: "BuRd" },
marks: [
Plot.dot(lfpPoints, {
x: "x",
y: "y",
r: 10,
stroke: "charge",
strokeWidth: 3
}),
Plot.text(lfpPoints, {
x: "x",
y: "y",
text: (d) => (d.charge > 0 ? "+" : "-"),
fontSize: 30
}),
Plot.dot(bounding.surroundings, { x: "x", y: "y", opacity: 0.1 }),
Plot.frame({ opacity: 0.2 })
]
});
const surroundings = updateSurroundings(),
m = d3.max(
surroundings
.map((d) => Math.abs(d.fieldX))
.concat(surroundings.map((d) => Math.abs(d.fieldY)))
),
scale2 = d3.scaleLinear().domain([-m, m]).range([-2, 2]);
const plt2 = Plot.plot({
width: 400,
aspectRatio: 1.0,
grid: true,
x: { nice: true, domain: bounding.range.x },
y: { nice: true, domain: bounding.range.y },
color: { nice: true, legend: true, scheme: "BuRd" },
marks: [
Plot.dot(surroundings, {
x: "x",
y: "y",
r: "fieldStr",
fill: "fieldStrInNorm",
stroke: "white"
}),
Plot.link(surroundings, {
x1: "x",
y1: "y",
x2: (d) => d.x + scale2(d.fieldX),
y2: (d) => d.y + scale2(d.fieldY)
}),
Plot.dot(lfpPoints, {
x: "x",
y: "y",
r: 10,
stroke: "gray",
opacity: 0.5
}),
Plot.text(lfpPoints, {
x: "x",
y: "y",
text: (d) => (d.charge > 0 ? "+" : "-"),
fontSize: 30,
opacity: 0.5
}),
Plot.dot(bounding.surroundings, { x: "x", y: "y", opacity: 0.1 }),
Plot.frame({ opacity: 0.2 })
]
});
return htl.html`
<div style="display: flex">
${plt1}
${plt2}
</div>
`;
}