function makeScatterPlot(data, factor, year){
const margin = ({top: 100, right: 200, bottom: 40, left: 40});
const height = 450;
const width = 1300;
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("text")
.attr("text-anchor", "middle")
.attr("x", (margin.left + width - margin.right) / 2)
.attr("y", margin.top / 2)
.attr("font-weight", "bold")
.style("font-size", "25px")
.text(factor + " vs. medals won - " + year);
svg.append("text")
.attr("text-anchor", "middle")
.attr("x", (margin.left + width - margin.right) / 2)
.attr("y", height - 5)
.attr("font-weight", "bold")
.style("font-size", "15px")
.text(factor);
svg.append("text")
.attr("text-anchor", "start")
.attr("x", margin.left - 20)
.attr("y", margin.top - 15)
.attr("font-weight", "bold")
.style("font-size", "15px")
.text("medals won");
const x = factor == "host" ?
d3.scaleBand()
.domain(data.map(d => d[factor]))
: d3.scaleLog()
.domain([d3.min(data, d => d[factor]), d3.max(data, d => d[factor])]);
x.range([margin.left, width - margin.right])
const xAxis = g => g
.attr("transform", "translate(0," + (height - margin.bottom) + ")")
.call(d3.axisBottom(x))
svg.append("g")
.call(xAxis)
const y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.medals)])
.rangeRound([height - margin.bottom, margin.top]);
const yAxis = g => g
.attr("transform", "translate(" + (margin.left) + ",0)")
.call(d3.axisLeft(y))
svg.append("g")
.call(yAxis)
svg.append("g")
.selectAll("dot")
.data(data)
.enter()
.append("circle")
.attr("cx", (d) => factor == "host" ? x(d[factor]) + x.bandwidth()/2: x(d[factor]))
.attr("cy", (d) => y(d.medals))
.attr("r", (d) => 5)
.style("fill", "black");
return svg.node();
}