ENH: add XKCD colorname -> hex mapping#5775
Conversation
|
There are 100+ test failures from this (which is more like 30-40 unique tests once the pdf/png/svg sets are taken into account) where one of the overlapping colors is used. I am inclined to change the tests to use the 'short' colors which will still have the highest priority. |
- removed darksage, lightsage, sage which are colors we added in 1ac590e These colors are now included in the XKCD mapping - correct sandybrown which mpl had as '#FAA460' but should be '#F4A460' according to the w3 group, wikipedia, the copy of rgb.txt bundled in the emacs source, and the mapping that we had bundled with AGG for a while. The original value goes back to ec45d17
|
Minimizing test image replacements this way sounds fine to me. |
- convert the single-letter colors to hex in source - single path for looking up string -> hex -> rgb values
|
Having so many clashes doesn't really bother me. (i.e. having lots of clashes vs. a few clashes feels like the same about of problem in my mind). I agree with Eric -- fixing the test source code to force use of the old colors is way preferable over a mass regeneration of images for a sort of "unimportant" (unlikely to uncover bugs) reason. |
|
I had not realized initially that the X11 names are also the HTML / CSS On Mon, Jan 4, 2016 at 10:24 AM Michael Droettboom [email protected]
|
- prefer the CSS4 str -> hex values because they are the 'standard'. The xkcd colors might be 'better', but we are not the right place to lead that change. If users use CSS/HTML/X11 color in mpl they should expect it to match the same color set in html for embedding mpl figures into websites and such. - Provide entries in XKCD dict of all names (with and with out spaces) prefixed with XKCD. Thus to get XKCD's version of blue use `color='xkcdblue'
|
The current round of failures is caused by floats not round-tripping to rbg floats, ex In [15]: import matplotlib.colors as mc
In [16]: mc.hex2color(mc.rgb2hex((0, .5, 0)))
Out[16]: (0.0, 0.5019607843137255, 0.0)
In [17]: mc.hex2color(mc.rgb2hex((0, .75, 0.75)))
Out[17]: (0.0, 0.7490196078431373, 0.7490196078431373)and in my attempt to simplify handling of the single letter mappings I converted the hard-coded tuples to hard-coded hex values. This is what is causing the tiny differences. Interestingly, I think this mean |
The hex representations are not exact which resulted in very small slight color changes.
|
I think all we need to ensure is that the precision of the hex numbers (8-bits per plane) is retained. Most of our displays can't display more precision than that anyway. should hold true. But the inverse doesn't really matter. |
|
I suspect the failed tests where cases where anti-aliasing was involved and 1 bit got changed. |
In [116]: ll = [str(i) for i in range(10)] + ['a', 'b', 'c', 'd', 'e', 'f']
In [117]: h = map(lambda x: '#'+''.join(x), itertools.product(*([ll] * 6)))
In [118]: import matplotlib.colors as mc
In [119]: for _ in h:
.....: assert _ == mc.rgb2hex(mc.hex2color(_))
.....: This completes sucessfully, but take too long to run to be worth putting in the test suite. |
|
Yes, 'g', 'y' and 'm' have always been slightly different. I don't know the On Mon, Jan 18, 2016 at 8:46 PM, Thomas A Caswell [email protected]
|
ColorConverter lowercases everything on the way in.
This dictionary was added in matplotlib#5775 sha: 9655f45 (and not yet released) and was removed from internal use by matplotlib#6382 sha: (master) 22a7b95 / (2.x backport) 3281bcd

This still needs
sort out how to make this configurableDoing this naively with an rcparam is tricky because
rcsetupimport colors which is imported by__init__.We could :
'X11_'so you could be sure to get that if you wanted ithasattrcheckscloses #4383