Discretized Color Scales

Cars scatterplot of horsepower and fuel economy
Quantitative positions with nominal color.
Cars scatterplot of horsepower and fuel economy
Quantitative positions with nominal color.

Discretized point color

Quantitative point color can create concrete color classes instead of a continuous gradient:

program.encodeColor({
  field: "life_expect",
  fieldType: "quantitative",
  scale: {
    type: "threshold",
    domain: [60, 70, 75, 80],
    range: ["#440154", "#3b528b", "#21918c", "#5ec962", "#fde725"]
  }
});

An exact boundary belongs to the upper interval. reverse: true reverses the resolved colors without changing boundaries. createLegend() infers an interval legend with labels such as < 60, 60–70, and ≥ 80. These mappings are available through quantitative point encodeColor and the direct scale vocabulary. A type-changing editScale call validates the complete replacement definition before rematerializing its consumers.

Scale overview · Encodings · Troubleshooting