chart = Plot.plot({
marks: [
Plot.dot(penguinsComplete, {
x: "flipper_length_mm",
y: "body_mass_g",
fill: "blue",
r: 4,
opacity: 0.4
}),
Plot.linearRegressionY(penguinsComplete, {
x: "flipper_length_mm",
y: "body_mass_g"
}),
Plot.text(
[`y = ${penguins_coefficients[1].toFixed(1)}x - ${-penguins_coefficients[0].toFixed(1)}
𝘙 ² = ${penguins_corr.r2.toFixed(2)}
𝘳 = ${penguins_corr.r.toFixed(2)}`
],
{frameAnchor: "bottom-right",
dy: -20,
fontSize: 16,
fill: "blue",
fontWeight: 600}
)
]
})