Skip to content

Adding names to the color in the new Vega10 color cycle - #7343

Closed
trpham wants to merge 8 commits into
matplotlib:masterfrom
trpham:7248-Add-names-to-new-default-color-cycle
Closed

trpham wants to merge 8 commits into
matplotlib:masterfrom
trpham:7248-Add-names-to-new-default-color-cycle

Conversation

@trpham

@trpham trpham commented Oct 25, 2016 •

Copy link
Copy Markdown
Contributor

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

NelleV commented Oct 25, 2016

Copy link
Copy Markdown
Member

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

@NelleV NelleV left a comment

Copy link
Copy Markdown
Member

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.

Comment thread 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'}``

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

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

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

Comment thread lib/matplotlib/colors.py
"""
def __init__(self, name, N=256):
r"""
"""

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

Comment thread 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}

Copy link
Copy Markdown
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'

Comment thread lib/matplotlib/_color_data.py Outdated
'cyan': '#17becf'}


# Normalize name to "vega:<name>" to avoid name collisions.

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread 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',

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread 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',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@NelleV

NelleV commented Oct 29, 2016

Copy link
Copy Markdown
Member

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

@QuLogic QuLogic left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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

NelleV commented Oct 31, 2016

Copy link
Copy Markdown
Member

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

@QuLogic

QuLogic commented Oct 31, 2016

Copy link
Copy Markdown
Member

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

NelleV commented Oct 31, 2016

Copy link
Copy Markdown
Member

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

NelleV commented Nov 1, 2016

Copy link
Copy Markdown
Member

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

NelleV commented Nov 8, 2016

Copy link
Copy Markdown
Member

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

@anntzer

anntzer commented Nov 10, 2016

Copy link
Copy Markdown
Contributor

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

QuLogic commented Nov 10, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

I will come back to this tonight or this weekend.

'cyan': '#17becf'}


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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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