-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Adding names to the color in the new Vega10 color cycle #7343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding names to the color in the new Vega10 color cycle #7343
Conversation
Hi @trpham |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -17,6 +17,7 @@ it can be provided as: | |||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
|
||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
@@ -401,7 +402,7 @@ class Colormap(object): | |||
|
|||
""" | |||
def __init__(self, name, N=256): | |||
r""" | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
'pink': '#e377c2', | ||
'gray': '#7f7f7f', | ||
'olive': '#bcbd22', | ||
'cyan': '#17becf'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pep8 might want that closing brace to be on the next line. Not sure though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't. That line is fine pep8-wise.
… pep8 style for VEGA10_COLORS dictionary in _color_data.py
@@ -250,7 +251,7 @@ def to_hex(c, keep_alpha=False): | |||
### Backwards-compatible color-conversion API | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 10 is missing in the name: it should be 'vega10'
'cyan': '#17becf'} | ||
|
||
|
||
# Normalize name to "vega:<name>" to avoid name collisions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we decided on 'vega10'
as the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there was a consensus on that (and I'm not sure it's necessary either.)
@@ -17,6 +17,9 @@ it can be provided as: | |||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just do not put the line break in?
…for vega10 dictionary description in colors.rst
* 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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There is still a test missing. Apart from that, it looks good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is wrong, it's "vega:".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(... 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"