It's using Math.random, so no it's not currently possible. You'd have to replace the Math.random calls with something like this: https://github.com/davidbau/seedrandom
Self plug. Autumn.js will do this if you pass it the same keys both times. Or it will do it by default if you call it with no arguments. https://github.com/nluqo/autumn
That page has a nice graphic clearly showing the problems with HSV and HSL. But the color scheme HSP it invents is not ideal. HUSL (http://www.boronine.com/husl/) is a strict improvement, as you can see from its comparison table of HUSL vs. HSL. HSP fixes the “lightness” problem with HSL, and HUSL fixes that as well as the “hue uniformity” problem.
Judging from the little interactive diagrams in your link #1, the author has set up the CIELAB and RGB color spaces with different white points, without doing any kind of chromatic adaptation transform in between. As a result, the widget presents a sort of pale orangish-brownish color as 'neutral' and all the slices related to hue and chroma are noticeably off. It’s an unfortunate oversight, because it makes them much more confusing than they would otherwise be.
In general, I’d recommend people use the CIECAM02 color space for most of the purposes being discussed in this thread. Here’s my implementation: https://github.com/jrus/chromatist
"BRIGHT COLORS" and "DARK COLORS" overlap with several dark colors. pretty much every color model gets brightness values that dont jive with perceptual reality.
A really important thing for data-vis is generating distinguishably different random colors. It'd be great to have a library that produces series of distinguishable, pleasing colors.
As the link says, “it's not perfect, as it doesn't take into account the different visual acuity of the human eye in different color channels”. That is why HSV is not appropriate – its H, S, and V scales are only approximations of axes that categorize colors as humans perceive them. For instance, V (value) roughly corresponds to how light or dark a color is, but blue with maximum V is way darker than yellow with maximum V.
I don’t know what the best model is. HSL, at least, is a simple-to-understand strict improvement over HSV. Other people in this thread are suggesting models I don’t know much about like CIELAB and CIECAM02. A model I have used to choose colors before, which is a variation of CIELUV and an improvement over HSL, is HUSL: http://www.boronine.com/husl/.
I have a library that does this. It picks random colors in the RGB space (or any subspace) and then uses simulated annealing to optimise the distance between the colors in CIE LAB:
I am no expert in this field, I just implemented the work of C.A. Glasbey, et al., 2006 :). We use it in one visualisation and the result is pleasing to my eye ;).
really like it. did some research before on how to generate colours that would be good for some simple visualizations, but found it difficult. This is great for a quick retrieval of colours that you can use!
I went with the approach of hardcoding few sets generated by http://tools.medialab.sciences-po.fr/iwanthue/ (which i think already been covered on HN) in my app. Just one set when i need <= 5 colors, one for <= 20, 50 and 100. Oh, and alternative set with different palette of colors when I need two diagrams on the same page. As a colorblind person I must say I was very happy with the results.
I wrote a general purpose (pseudo-)random value generation library[0] that does random color generation[1] among lots of other capabilities. It'd be interesting to see how you could use the mutator to implement some of this functionality.
29 comments
[ 4.9 ms ] story [ 70.0 ms ] threadSince HSV is NOT perceived as evenly distributed to the human eye along the value(lightness) axis[1],
would recommend employing chroma.js[2] which uses the HCL and CIE color spaces, which in general yield more pleasing results for use in color scales.
[1] http://vis4.net/blog/posts/avoid-equidistant-hsv-colors/
[2] https://github.com/gka/chroma.js
i want hue might be a bit of overkill though: http://tools.medialab.sciences-po.fr/iwanthue/index.php
In general, I’d recommend people use the CIECAM02 color space for most of the purposes being discussed in this thread. Here’s my implementation: https://github.com/jrus/chromatist
"Picking a range of colors": http://wiki.tcl.tk/38935
I don’t know what the best model is. HSL, at least, is a simple-to-understand strict improvement over HSV. Other people in this thread are suggesting models I don’t know much about like CIELAB and CIECAM02. A model I have used to choose colors before, which is a variation of CIELUV and an improvement over HSL, is HUSL: http://www.boronine.com/husl/.
https://github.com/danieldk/quzah
I am no expert in this field, I just implemented the work of C.A. Glasbey, et al., 2006 :). We use it in one visualisation and the result is pleasing to my eye ;).
http://martin.ankerl.com/2009/12/09/how-to-create-random-col...
http://bl.ocks.org/mbostock/5577023
https://github.com/mbostock/d3/tree/master/lib/colorbrewer
[0] https://github.com/heydenberk/stochator [1] https://github.com/heydenberk/stochator#from-predefined-sets