Sort Scatterplot

I have attached my plot function and a picture of the scatterplot. Can you please help me figure out how to sort the scatterplot correctly so that the x and y axes are sorted correctly to display the correct graph?

  grid: true,
  inset: 10,
  x: {label: "home runs"},
  y: {label: "hits"},
  marks: [, {x: "homeRuns", y: "hits", stroke: "playerName", r: "homeRuns", channels: {team: "teamName"}, tip: true,}),

Try and modify mlb_homeruns_stats so that the homeRuns and hits fields are numbers. If you load the values with the FileAttachment.csv method, you can use the {typed: true} option to do so. Another possibility is to type the x and y axes with:

x: {type: "linear"},
y: {type: "linear"},

I was able to add the {typed:true} and it worked! Thanks for the tip!

1 Like