2

According to the D3 Wiki. there is a scale function d3.scale.category20() that

Constructs a new ordinal scale with a range of twenty categorical colors:

Question: is there anything that one can do to generate more than 20 unique colors? I was hoping to get at least 50.

Leahcim
  • 40,649
  • 59
  • 195
  • 334

1 Answers1

2

By looking at the source code for that method:

d3.scale.category20 = function() {
    return d3.scale.ordinal().range(d3_category20);
};
var d3_category20 = [
  0x1f77b4, 0xaec7e8,
  0xff7f0e, 0xffbb78,
  0x2ca02c, 0x98df8a,
  0xd62728, 0xff9896,
  0x9467bd, 0xc5b0d5,
  0x8c564b, 0xc49c94,
  0xe377c2, 0xf7b6d2,
  0x7f7f7f, 0xc7c7c7,
  0xbcbd22, 0xdbdb8d,
  0x17becf, 0x9edae5
].map(d3_rgbString);

You should be able to call d3.scale.ordinal().range(...) on your own color list.