How to combine two or more color schemes for use in Observable plot?

Hello All,

I have data with high cardinality, and I need to combine two or more sets of discrete colors. How do I do it? For example, I have used the “dark2” scheme in the code-snippet below. How do I add “category10” or pastel1" to “dark2” for use in the same graph?

color: {
type: “categorical”,
scheme: "dark2
}

Thanks in advance,
Rini

You might want to try color: {range: d3.schemeDark2.concat(d3.schemeCategory10) }, or define a list of cateogorical colors yourself, and feed it as an array color: {range: ["#fff", "#ccc",…] }.

1 Like

Thanks so much! How do I concat more that 2 schemes?
And how does the code appear
(1 )in the domain, range format,
and (2) when creating swatches for legend?

I guess they would be nested:


let colours = d3.schemeDark2.concat(d3.schemeCategory10.concat(d3.schemeSet3))

let myScale = d3.scaleLinear()
  .domain([0, colours.length])
  .range([0, 600]);

1 Like