{
const svg = d3.create('svg')
.attr('width', visWidth + margin.left + margin.right)
.attr('height', visHeight + margin.top + margin.bottom);
const x = d3.scaleLinear()
.domain(d3.extent(iris, d => d.sepalLength)).nice()
.range([0, visWidth]);
const y = d3.scaleLinear()
.domain(d3.extent(iris, d => d.sepalWidth)).nice()
.range([visHeight, 0]);
const color = d3.scaleOrdinal()
.domain(species)
.range(d3.schemeCategory10);
const g = svg.append("g")
.attr("transform", `translate(${margin.left}, ${margin.top})`);
const xAxis = d3.axisBottom(x);
const yAxis = d3.axisLeft(y);
g.append('g')
.attr('transform', `translate(0, ${visHeight})`)
.call(xAxis)
.append("text")
.attr("x", visWidth / 2)
.attr("y", 40)
.attr("fill", "black")
.attr("text-anchor", "middle")
.text("sepal length (cm)");
g.append("g")
.call(yAxis)
.append("text")
.attr("x", -40)
.attr("y", visHeight/2)
.attr("fill", "black")
.attr("dominant-baseline", "middle")
.text("sepal width (cm)");
g.append('g').selectAll("circle")
.data(iris)
.join("circle")
.attr("cx", d => x(d.sepalLength))
.attr("cy", d => y(d.sepalWidth))
.attr("fill", d => color(d.species))
.attr("r", 3);
return svg.node();
}