function plot_scatter(data) {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const set_font_primary = node => node.attr("font-family", "Arial Narrow");
const add_tspan = (text, string) =>
text
.append("tspan")
.text(string)
.attr("style", "display: block");
svg
.append("text")
.call(set_font_primary)
.attr("x", margin.left)
.attr("y", margin.top / 3)
.call(
add_tspan,
"Alcohol content, bitterness, and acidity of beers from the Punk API"
);
svg
.append("g")
.call(set_font_primary)
.call(xAxis);
svg
.append("g")
.call(set_font_primary)
.call(yAxis);
svg
.append("g")
.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", d => x(d.abv))
.attr("cy", d => y(d.ibu))
.attr("r", 3)
.attr("fill", d => fill(d.ph));
svg
.append("text")
.call(set_font_primary)
.attr("text-anchor", "end")
.attr("x", width)
.attr("y", height - margin.top / 3)
.text("ABV");
svg
.append("text")
.call(set_font_primary)
.attr("text-anchor", "end")
.attr("transform", "rotate(-90)")
.attr("y", margin.left / 3)
.attr("x", -margin.top)
.text("IBU");
svg.selectAll(".tick:first-child line").attr("stroke", "#ffffff");
svg.selectAll(".tick:not(:first-child) line").attr("stroke", "#ebebeb");
return svg.node();
}