Closed neuhaus closed 6 years ago
This is an excellent idea. There's also d3.scale if you don't want to do math by hand:
const getColor = d3.scaleLinear()
.domain([0, 20]) // Max value for trait commonality
.interpolate(d3.interpolateCool); // The color scale you want to use
// Now, you can get your colors by saying something like:
const jaguarColor = getColor(tbl.jaguar.count);
Consider using log(count) so the most interesting part (the rare ones) are distinguishable
Agree with @neuhaus. I like having the top 50% most common be white so they can be ignored easily.
Tested it out and much prefer the current method.
Hi,
using a HSV palette you could make the colours reflect exactly how rare the trait is.
Here's a function you can use, i converted it from Java code to javascript:
If you want the resulting colors to run from green to red, use a hue value between 120 and 400 (subtract 360 from h if the result is >360 before calling the function)