{
const svg = d3.create('svg')
.attr('width', widthPop)
.attr('height', heightPop);
svg.append('g')
.selectAll('line')
.data(populations)
.join('line')
.attr('x1', d => countryScale_vertical(d.country) + countryScale_vertical.bandwidth() / 2)
.attr('x2', d=> countryScale_vertical(d.country) + countryScale_vertical.bandwidth() / 2)
.attr('y1', populationScale_vertical(0))
.attr('y2', d => populationScale_vertical(d.population))
.attr('stroke', 'steelblue')
.attr('stroke-width', 3)
svg.append('g')
.selectAll('circle')
.data(populations)
.join('circle')
.attr('cx', d => countryScale_vertical(d.country) + countryScale_vertical.bandwidth() /2)
.attr('cy', d => populationScale_vertical(d.population))
.attr('r', 6)
.attr('fill', 'steelblue')
svg.append('line')
.attr('x1', marginPop.left)
.attr('x2', widthPop - marginPop.right)
.attr('y1', populationScale_vertical(meanPopulation))
.attr('y2', populationScale_vertical(meanPopulation))
.attr('stroke', 'red')
.attr('stroke-width', 2)
svg.append('g')
.attr('transform', `translate(${marginPop.left}, 0)`)
.call(yAxisPop_vertical)
.call(g => g.select('.domain').remove());
svg.append('g')
.attr('transform', `translate(0, ${heightPop - marginPop.bottom})`)
.call(xAxisPop_vertical)
.call(g => g.select('.domain').remove())
svg.append('text')
.attr('fill', 'black')
.attr('font-family', 'sans-serif')
.attr('x', widthPop / 2)
.attr('y', heightPop)
.text('Población');
return svg.node();
}