Skip to content

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

Conversation

trpham
Copy link
Contributor

@trpham trpham commented Oct 25, 2016

Prefer to this ticket: #7248 "Adding names to the color in the new (Vega) default color cycle"

  • Implement VEGA10_COLORS dictionary package in _color_data.py,
  • Use name colors, prefix vega10:__ (where __ is blue, orange, green, red, purple, brown, pink, gray, olive, cyan), respectively equivalent to C0, C1,..., C9
  • In colors.py, import VEGA10_COLORS, and add this new dictionary into _colors_full_map

@NelleV
Copy link
Member

NelleV commented Oct 25, 2016

Hi @trpham
When submitting a pull request, please add a description of the feature added or the bug fixed.
Else, the reviewers have no clue what the patch proposes.

@NelleV NelleV changed the title Adding names to the color in the new Vega10 color cycle [WIP] Adding names to the color in the new Vega10 color cycle Oct 25, 2016
NelleV
NelleV previously requested changes Oct 26, 2016
Copy link
Member

@NelleV NelleV left a 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'}``
Copy link
Member

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.

Copy link
Contributor Author

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()}
Copy link
Member

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.

Copy link
Contributor Author

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"""
"""
Copy link
Member

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'}
Copy link
Member

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.

Copy link
Member

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.

@@ -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}
Copy link
Member

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.
Copy link
Member

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.

Copy link
Member

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.)

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Oct 26, 2016
@@ -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',
Copy link
Member

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.

Copy link
Member

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@NelleV
Copy link
Member

NelleV commented Oct 29, 2016

There is still a test missing. Apart from that, it looks good!

Copy link
Member

@QuLogic QuLogic left a 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.

@tacaswell
Copy link
Member

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.

@NelleV
Copy link
Member

NelleV commented Oct 31, 2016

I must be missing something… What's the link between Tableau and D3 (/vega)?

@QuLogic
Copy link
Member

QuLogic commented Oct 31, 2016

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., blue1, blue2, blue3, ,blue4, because they're all variants of the same colour. But anyway, this is why we should not split the discussion between these two tickets.

@NelleV
Copy link
Member

NelleV commented Oct 31, 2016

I am fine with either, but we need to be entirely sure that there is no possible overlap with the names.

@NelleV NelleV modified the milestones: 2.0.1 (next bug fix release), 2.0 (style change major release) Oct 31, 2016
@NelleV
Copy link
Member

NelleV commented Nov 1, 2016

I think we should not merge this for 2.0 but keep in for 2.1.
The naming is not that easy, and it's going to take some time to pin it down correctly. We should not rush it for 2.0.

@NelleV NelleV modified the milestones: 2.1 (next point release), 2.0.1 (next bug fix release) Nov 1, 2016
@NelleV NelleV dismissed their stale review November 8, 2016 18:58

Elements are fixed

@NelleV NelleV changed the title [WIP] Adding names to the color in the new Vega10 color cycle [MRG+1] Adding names to the color in the new Vega10 color cycle Nov 8, 2016
@NelleV
Copy link
Member

NelleV commented Nov 8, 2016

This looks good to me.
@tacaswell should this go in 2.1 or 2.0?

@anntzer
Copy link
Contributor

anntzer commented Nov 10, 2016

I strongly favor 2.0 from a usability POV.

@QuLogic QuLogic dismissed their stale review November 10, 2016 22:41

Updates have been made.

@QuLogic
Copy link
Member

QuLogic commented Nov 10, 2016

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()}

Copy link
Contributor

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.

Copy link
Member

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.

@tacaswell
Copy link
Member

I will come back to this tonight or this weekend.

'cyan': '#17becf'}


# Normalize name to "vega10:<name>" to avoid name collisions.
Copy link
Contributor

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:".

Copy link
Contributor

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...)

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.1 (next point release) Jan 10, 2017
@tacaswell
Copy link
Member

Closing this to reduce confusion.

@tacaswell tacaswell closed this Jan 10, 2017
@QuLogic QuLogic changed the title [MRG+1] Adding names to the color in the new Vega10 color cycle Adding names to the color in the new Vega10 color cycle Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants