{
const svg = d3.create("svg")
.attr("width",width)
.attr("height",height);
svg.append("g")
.attr("transform", `translate(0, ${height - margin.bottom})`)
.call(d3.axisBottom(x));
svg.append("g")
.attr("transform", `translate(${margin.left}, 0)`)
.call(d3.axisLeft(y));
svg.append("text")
.attr("x", width / 2)
.attr("y", height - 5)
.attr("font-size", "8px")
.attr("text-anchor", "middle")
.text(ejeX);
svg.append("text")
.attr("transform", "rotate(-90)")
.attr("x", -height / 2)
.attr("y", 15)
.attr("font-size", "8px")
.attr("text-anchor", "middle")
.text(ejeY);
svg.selectAll("circle")
.data(datosFiltrados)
.join("circle")
.attr("cx", d => x(d[ejeX]))
.attr("cy", d => y(d[ejeY]))
.attr("r", 4)
.attr("fill", "steelblue")
.attr("opacity", 0.7)
svg.append("text")
.attr("x", width / 2)
.attr("y", margin.top - 20)
.attr("text-anchor", "middle")
.attr("font-size", "10px")
.text(`Gráfico de dispersión: ${ejeX} vs. ${ejeY}`);
return svg.node();
}