Adding names to the color in the new Vega10 color cycle#7343
Adding names to the color in the new Vega10 color cycle#7343trpham wants to merge 8 commits intomatplotlib:masterfrom
Conversation
|
Hi @trpham |
NelleV
left a comment
There was a problem hiding this comment.
In terms of code, this is mostly good (apart from the pep8 violation).
We are missing a test: Look at lib/matplotlib/tests/test_colors.py l: 575 how it's done for the xkcd.
I'd also like to have a bit more documentation, but I haven't figured out a good way to do this, so I'll get back to you on that.
doc/users/colors.rst
Outdated
| * a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__ | ||
| prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``) | ||
| * one of ``{'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'}`` | ||
| * one of ``{'blue', 'orange', 'green', 'red', 'purple', 'brown', 'pink', 'gray', 'olive', 'cyan'}`` |
There was a problem hiding this comment.
Thanks for thinking about documenting this change! That's a really important part of making new features accessible to users.
I think you should add the "vega" prefix to be more specific.
lib/matplotlib/_color_data.py
Outdated
|
|
||
|
|
||
| # Normalize name to "vega:<name>" to avoid name collisions. | ||
| VEGA10_COLORS = {'vega:' + name: value for name, value in VEGA10_COLORS.items()} |
There was a problem hiding this comment.
That line is slightly too long for pep8 (1 character too long). The tests are failing because of this line.
There was a problem hiding this comment.
@NelleV I did notice that, but it's exactly 80 characters, and I thought leave it like that way is cleaner. Let's me fix it.
| """ | ||
| def __init__(self, name, N=256): | ||
| r""" | ||
| """ |
| 'pink': '#e377c2', | ||
| 'gray': '#7f7f7f', | ||
| 'olive': '#bcbd22', | ||
| 'cyan': '#17becf'} |
There was a problem hiding this comment.
pep8 might want that closing brace to be on the next line. Not sure though.
There was a problem hiding this comment.
It doesn't. That line is fine pep8-wise.
… pep8 style for VEGA10_COLORS dictionary in _color_data.py
lib/matplotlib/colors.py
Outdated
|
|
||
| cnames = CSS4_COLORS | ||
| COLOR_NAMES = {'xkcd': XKCD_COLORS, 'css4': CSS4_COLORS} | ||
| COLOR_NAMES = {'xkcd': XKCD_COLORS, 'css4': CSS4_COLORS, 'vega': VEGA10_COLORS} |
There was a problem hiding this comment.
The 10 is missing in the name: it should be 'vega10'
lib/matplotlib/_color_data.py
Outdated
| 'cyan': '#17becf'} | ||
|
|
||
|
|
||
| # Normalize name to "vega:<name>" to avoid name collisions. |
There was a problem hiding this comment.
I think we decided on 'vega10' as the prefix.
There was a problem hiding this comment.
I don't think there was a consensus on that (and I'm not sure it's necessary either.)
doc/users/colors.rst
Outdated
| * a name from the `xkcd color survey <https://xkcd.com/color/rgb/>`__ | ||
| prefixed with ``'xkcd:'`` (e.g., ``'xkcd:sky blue'``) | ||
| * one of ``{'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'}`` | ||
| * one of ``{'vega10:blue', 'vega10:orange', 'vega10:green', 'vega10:red', |
There was a problem hiding this comment.
sphinx is not happy about this line… It says:
/home/travis/build/matplotlib/matplotlib/doc/users/colors.rst:22: WARNING: Inline literal start-string without end-string.
I think it is upset that the literal is on several line, but we don't want a block… We'll need to find a solution.
There was a problem hiding this comment.
I think just do not put the line break in?
…for vega10 dictionary description in colors.rst
doc/users/colors.rst
Outdated
| * one of ``{'vega10:blue', 'vega10:orange', 'vega10:green', 'vega10:red', | ||
| 'vega10:purple', 'vega10:brown', 'vega10:pink', 'vega10:gray', | ||
| 'vega10:olive', 'vega10:cyan'}`` | ||
| * one of ``{'vega10:blue', 'vega10:orange', 'vega10:green', |
|
There is still a test missing. Apart from that, it looks good! |
QuLogic
left a comment
There was a problem hiding this comment.
I'm still against the 10 in the prefix, and I don't think it was properly decided in #7248.
Still waiting for @tacaswell to finish conversation with Tableau and UW, so I'm not really asking for changes, but just blocking on merge (not that this is really binding) until that's resolved.
|
This PR should not be held on the Tableau/UW discussion. There probably does need to be some 10 in the name as we are using 'category10', there is also 'category20' (which is category 10 + lightened variants) and 'category20b' and 'category20c'. The later two have colors that you would want to use the 'simple' names for and will collide with 'c10' / 'c20'. how about 'vc10' for this namespace? That might be too obscure. |
|
I must be missing something… What's the link between Tableau and D3 (/vega)? |
|
Yes, category20 is just the light version of category10; that's why I don't think you need the 10. Category10 is the default, thus it is the most likely to be used (except perhaps for non-prefixed colours.) Why add these redundant two characters to every single usage? I'm talking about overall impact to whatever insert-large-number-here of lines is written by the entire userbase, not just the small effect it has on the setup here. For category20b & c, @anntzer suggested, e.g., |
|
I am fine with either, but we need to be entirely sure that there is no possible overlap with the names. |
|
I think we should not merge this for 2.0 but keep in for 2.1. |
|
This looks good to me. |
|
I strongly favor 2.0 from a usability POV. |
|
The only comment I have is there should be a 'grey' spelling as well. |
|
|
||
| # Normalize name to "vega10:<name>" to avoid name collisions. | ||
| VEGA_COLORS = {'vega:' + name: value for name, value in VEGA_COLORS.items()} | ||
|
|
There was a problem hiding this comment.
Maybe change this dictionary comprehension to a for loop for better readability? It seems like too much is being done in one statement.
There was a problem hiding this comment.
As far as comprehensions go, this one is pretty simple; I don't think it needs to be rewritten. At most, add a break before for.
|
I will come back to this tonight or this weekend. |
| 'cyan': '#17becf'} | ||
|
|
||
|
|
||
| # Normalize name to "vega10:<name>" to avoid name collisions. |
There was a problem hiding this comment.
The comment is wrong, it's "vega:".
There was a problem hiding this comment.
(... didn't notice this PR has been superseded by #7639...)
|
Closing this to reduce confusion. |
Prefer to this ticket: #7248 "Adding names to the color in the new (Vega) default color cycle"