{
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);
const datosFiltrados = data.filter(d => d.Species === especieSeleccionada);
svg.selectAll("circle")
.data(datosFiltrados)
.join("circle")
.attr("cx", d => x(d[ejeX]))
.attr("cy", d => y(d[EjeY]))
.attr("r", 4)
.attr("fill", "green")
.attr("opacity", 0.7);
svg.append("text")
.attr("x", width / 2)
.attr("y", margin.top - 10)
.attr("text-anchor", "middle")
.attr("font-size", "10px")
.text(`${ejeX} vs. ${EjeY} (Especie: ${especieSeleccionada})`);
return svg.node();
}