Public
Edited
Jul 11, 2024
1 fork
Insert cell
Insert cell
get_headshot_url = (player_id) =>
`https://img.mlbstatic.com/mlb-photos/image/upload/v1/people/${player_id}/headshot/67/current`
Insert cell
x = "woba"
Insert cell
y = "est_woba"
Insert cell
Plot.plot({
width: width * 0.75,
aspectRatio: 2,
x: {
domain: [
_.min(expected_stats.map((e) => e[x])) * 0.9,
_.max(expected_stats.map((e) => e[x])) * 1.1
]
},
y: {
domain: [
_.min(expected_stats.map((e) => e[y])) * 0.9,
_.max(expected_stats.map((e) => e[y])) * 1.1
]
},
// y: { domain: [0.2, 0.] },
marks: [
Plot.ruleY([0]),
Plot.line(
[
[0, 0],
[1, 1]
],
{ stroke: "red", strokeDasharray: ".-" }
),
Plot.linearRegressionY(expected_stats, { x, y }),
Plot.image(expected_stats, {
x,
y,
src: (d) => get_headshot_url(d.player_id),
r: 20,
title: "last_name, first_name"
})
]
})
Insert cell
expected_stats.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more