function appendHistogram(group, data, accessor, width, height, xAxisText, yAxisSupplementText, prob=false) {
let bins = d3.bin()
.thresholds(40)
.value(accessor)
(data);
let x = d3.scaleLinear()
.domain([bins[0].x0, bins[bins.length - 1].x1])
.range([0, width]);
group.append("g")
.attr("transform", `translate(0, ${height})`)
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
.call((g) => g.append("text")
.attr("x", width)
.attr("y", 25)
.attr("fill", "currentColor")
.attr("text-anchor", "end")
.text(`${xAxisText.length == 0 ? "Rate" : xAxisText} →`));
group.append("g")
.attr("transform", `translate(0, ${height})`)
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0));
let totalCount = 1
if (prob) {
totalCount = data.length;
}
let y = d3.scaleLinear()
.domain([0, d3.max(bins, (d) => d.length / totalCount)])
.range([height, 0]);
const yAxisAnnotation = prob ? "Prob." : "Freq.";
group.append("g")
.call(d3.axisLeft(y).ticks(height / 40))
.call((g) => g.select(".domain").remove())
.call((g) => g.append("text")
.attr("x", -20)
.attr("y", -30)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(`↑ ${yAxisAnnotation} ${yAxisSupplementText}`));
group.append("g")
.attr("fill", "steelblue")
.selectAll()
.data(bins)
.join("rect")
.attr("x", (d) => x(d.x0) + 1)
.attr("width", (d) => x(d.x1) - x(d.x0)- 1)
.attr("y", (d) => y(d.length / totalCount))
.attr("height", (d) => y(0) - y(d.length / totalCount));
}