{
const width = 350;
const height = 350;
const margin = { top: 40, right: 40, bottom: 40, left: 40 };
const innerWidth = width - margin.left - margin.right;
const innerHeight = height - margin.top - margin.bottom;
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const g = svg.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
const x = d3.scaleLinear()
.domain(d3.extent(irisFiltered, d => d[xAttr]))
.range([0, innerWidth]);
const y = d3.scaleLinear()
.domain(d3.extent(irisFiltered, d => d[yAttr]))
.range([innerHeight, 0]);
g.append("g")
.attr("transform", `translate(0,${innerHeight})`)
.call(d3.axisBottom(x));
g.append("g")
.call(d3.axisLeft(y));
g.selectAll("circle")
.data(irisFiltered)
.enter()
.append("circle")
.attr("cx", d => x(d[xAttr]))
.attr("cy", d => y(d[yAttr]))
.attr("r", 5)
.attr("fill", "#69b3a2")
.attr("opacity", 0.7);
g.append("text")
.attr("x", innerWidth / 2)
.attr("y", innerHeight + 30)
.attr("text-anchor", "middle")
.text(xAttr.replace("_", " "));
g.append("text")
.attr("transform", "rotate(-90)")
.attr("x", -innerHeight / 2)
.attr("y", -30)
.attr("text-anchor", "middle")
.text(yAttr.replace("_", " "));
return svg.node();
}