Plot.plot({
marks: [
Plot.dot(scoresCombined, {
x: "PC1",
y: "PC2",
fill: "season",
r: 4
}),
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"
})
],
color: {legend: true}
})