{
const svg = d3.create("svg")
.attr("width",ancho)
.attr("height",alto);
svg.append("g")
.call(eje_x);
svg.append("g")
.call(eje_y);
svg.append('g')
.selectAll("dot")
.data(datos_iris.filter(filtro))
.enter()
.append("circle")
.attr("cx", function (d) { return x(d[campo_x]); } )
.attr("cy", function (d) { return y(d[campo_y]); } )
.attr("r", 3 )
.style("fill", function (d) { return d.color; });
const escala = d3.scaleOrdinal()
.domain("setosa", "versicolor", "virginica")
.range([color_especies["setosa"],
color_especies["versicolor"],
color_especies["virginica"], "#FFFFFF", "#FFFFFF"]);
const leyenda = d3Legend
.legendColor()
.shape("path", d3.symbol().type(d3.symbolCircle).size(25)())
.shapePadding(15)
.labelOffset(5)
.scale(escala)
.labels(["Setosa", "Versicolor", "Virgínica", "", ""]);
svg.append("g")
.attr("class", "legend_auto")
.style('font-size', 12)
.style('font-family', 'sans-serif')
.attr("transform", `translate(${ancho - margen.der-60}, ${margen.arr+270})`)
.call(leyenda)
svg.append("text")
.attr("class", "x label")
.attr("text-anchor", "end")
.attr("x", margen.izq+ancho/2)
.attr("y", alto - 10)
.text(campo_x);
svg.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("y", 5)
.attr("x", - alto/2 + margen.abj)
.attr("dy", ".75em")
.attr("transform", "rotate(-90)")
.text(campo_y);
return svg.node();
}