Plot.plot({ color: { legend: true, ...(colorType === "ordinal" ? { range: [ "green", "purple", "orange", "yellow", "blue", "pink", "brown", "grey", "green", "lavender" ] } : { scheme: "blues" }) }, marks: [ Plot.dot(diamonds, {-x: "depth", y: "table",+x: x, y: y,stroke: col, tip: true, channels: { Color: "color", Clarity: "clarity" } }) ], grid: true })
This solution allows to manually specify both categorical color palette and and a continuous color scheme when the color variable is not known in advance.