Plot.plot({
marks: [
Plot.dot(scoresCombined, { x: "PC1", y: "PC2", fill: "season", r: 5 }),
Plot.arrow(loadings, {
x1: 0,
x2: (d) => d.PC1 * scalingFactor,
y1: 0,
y2: (d) => d.PC2 * scalingFactor
}),
Plot.text(loadings, {
x: (d) => d.PC1 * scalingFactor,
y: (d) => d.PC2 * scalingFactor,
text: "Variable",
dy: -5,
dx: 30,
fill: "black",
stroke: "white"
})
],
color: { legend: true }
})