scatterplot_campos = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x_iris))
svg.append("g")
.attr ("transform",`translate(${margin.left},0)`)
.call(d3.axisLeft(y_iris));
svg.append("text")
.attr("x", width / 2)
.attr("y", height - 5)
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.text(campo_x);
svg.append("text")
.attr("transform", "rotate(-90)")
.attr("x", -height / 2)
.attr("y", 12)
.attr("text-anchor", "middle")
.style("font", "10px sans-serif")
.text(campo_y);
const color = d3.scaleOrdinal()
.domain(["setosa", "versicolor", "virginica"])
.range(["#1f77b4", "#ff7f0e", "#2ca02c"]);
svg.append("g")
.selectAll("circle")
.data(iris)
.join("circle")
.attr("cx", d => x_iris(d[campo_x]))
.attr("cy", d => y_iris(d[campo_y]))
.attr("r", 2)
.attr("fill", d => color (d.Species));
return svg.node();
}