Closed
Description
Below the domain implicitly has two elements [0, 39] while the specified range has three [red, green, blue]. The intended behavior is that the third element green in the range is ignored. However, the color legend incorrectly shows all three colors.

plot = Plot.plot({
color: {
legend: true,
type: "linear",
range: ["red", "blue", "green"]
},
marks: [
Plot.cellX(d3.range(40), {fill: Plot.identity})
]
})
In addition, the exposed color scale incorrectly shows a three-element range:
plot.scale("color").range // ["red", "blue", "green"]
If the domain of the same length is specified, the piecewise color scale works fine. It’s only a problem when the two don’t match.

Plot.plot({
color: {
legend: true,
type: "linear",
domain: [0, 39 / 2, 39],
range: ["red", "blue", "green"]
},
marks: [
Plot.cellX(d3.range(40), {fill: Plot.identity})
]
})