{
const width = 350;
const height = 350;
const margin = { top: 10, right: 10, bottom: 40, left: 40 };
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const g = svg.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
const innerWidth = width - margin.left - margin.right;
const innerHeight = height - margin.top - margin.bottom;
const x = d3.scaleLinear()
.domain(d3.extent(iris_filtered, d => d[x_var]))
.range([0, innerWidth]);
const y = d3.scaleLinear()
.domain(d3.extent(iris_filtered, d => d[y_var]))
.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(iris_filtered)
.join("circle")
.attr("cx", d => x(d[x_var]))
.attr("cy", d => y(d[y_var]))
.attr("r", 4)
.attr("fill", "#1f77b4");
return svg.node();
}