Skip to content

Adding names to the color in the new (Vega) default color cycle #7248

Closed

Description

@anntzer

The new default color cycle (Vega10, http://matplotlib.org/devdocs/users/dflt_style_changes.html#colors-color-cycles-and-color-maps) is pretty nice, but the colors are not named. Thus, the only way to refer to a specific color in that cycle is with the "Cn" syntax, which does not read as well.

For examples, consider something like

positive_values = ...
negative_values = ...
ax.plot(positive_values, c="C2")  # green-ish
ax.plot(negative_values, c="C3")  # red-ish

The intent is certainly less legible than

positive_values = ...
negative_values = ...
ax.plot(positive_values, c="g")
ax.plot(negative_values, c="r")

(using green for positive values and red for negative values is a not so rare convention).

(Of course, just using "g" and "r" or whatever CSS/XKCD color names doesn't really work either if you want to blend well with other figure elements that use the Vega10 palette.)

Thus, I'd suggest adding names to the colors of the Vega10/Vega20 palette, e.g. using the "vega:" prefix. Something like "blue", "orange", "green", "red", "purple", "brown", "pink", "gray", "yellow", "cyan" (all prefixed by "vega:" -- I don't think we can use "v:" due to the possible confusion with the triangle_down marker -- depends on the exact way the parser works...) looks close to what the colors are. The Vega20 palette (which adds lighter versions of all colors) can be supported as "vega:lightblue", etc. See https://github.com/vega/vega/wiki/Scales#scale-range-literals for the full palette.

Thoughts? The implementation itself is easy of course (just add the names to the named colors dict).

I think this should be milestoned to 2.0 or 2.0.1.

Activity

  1. added this to the milestone on Oct 11, 2016
  2. tacaswell commented on Oct 11, 2016

    @tacaswell
    Member

    Can not hurt, but we should make sure there is not an existing set of names for them.

    I am pretty 😐 on this.

  3. NelleV commented on Oct 11, 2016

    @NelleV
    Member

    I think that's a good idea

  4. anntzer commented on Oct 11, 2016

    @anntzer
    ContributorAuthor

    @NelleV Can the machine shop do this? :)

  5. NelleV commented on Oct 11, 2016

    @NelleV
    Member

    The machine shop sure can!

  6. anntzer commented on Oct 11, 2016

    @anntzer
    ContributorAuthor

    Doing the literature search suggested by @tacaswell (check whether they already have standard names) is also part of the assignment, hehe...

  7. trpham commented on Oct 17, 2016

    @trpham
    Contributor

    Not sure if I can use names from these references and try to match the color in vega cycle with those name using my naked eyes. Or any better way to do that?

    https://xkcd.com/color/rgb/
    https://en.wikipedia.org/wiki/X11_color_names
    https://en.wikipedia.org/wiki/Web_colors
    http://ingridsundberg.com/2014/02/04/the-color-thesaurus/
    http://chir.ag/projects/name-that-color/#D62728

    Also, something like: 'vega:steelblue' (for #1f77b4 ), 'vega:sienna' or 'vega:saddlebrown'( for #8c564b ) is hard to remember and long?

  8. NelleV commented on Oct 17, 2016

    @NelleV
    Member

    It'd be easier to find names if we had a way to see all colors that need to be named.
    I do think that steelblue and saddlebrown are sligthtly loo long and too hard to remember, so if we can avoid those and stick to easy ones (vega:oranage, vega:blue), that be nicer.

  9. anntzer commented on Oct 17, 2016

    @anntzer
    ContributorAuthor

    Updated OP with link to the Vega palettes. I think that because these will be the default colors, we should stick to relatively short names.

    As a side note, http://matplotlib.org/devdocs/examples/color/named_colors.html should be updated (I guess we'll have a new VEGA_COLORS dict). It may also make sense to sort the colors first by "category" in that plot (1. one-letter, 2. Vega, 3. CSS).

  10. NelleV commented on Oct 18, 2016

    @NelleV
    Member

    If I am not mistaken, it is only the first ten. There are only two redundant color (blue and green) so it should be quite straightforward

  11. tacaswell commented on Oct 18, 2016

    @tacaswell
    Member

    We should probably consult @jheer on these names (I have also sent him a private email, but he is out on paternity leave this semester).

    It is probably worth tracking down one of his students?

  12. tacaswell commented on Oct 18, 2016

    @tacaswell
    Member

    Also, this is tagged 'Easy', but naming thing is one of the two hard problems in CS:

    1. cache invalidation
    2. naming things
    3. off-by-one bugs
  13. 17 remaining items

  14. OceanWolf commented on Oct 19, 2016

    @OceanWolf
    Member

    Looking at the colour code _color_data.py I see we already have the xkcd names in there so that eradicates the need for separate fancy colour names as I see it.

    With the namespace, I suggest we put in the list of 20 colours as blue, lightblue, orange, lightorange, etctera, perhaps with a space or underscore, and then simply skip the light colours for assigning to the default prop_cycle, with d3 [::2].

  15. trpham commented on Nov 1, 2016

    @trpham
    Contributor

    The proposed naming convention that we are coming up with.
    vega

  16. NelleV commented on Nov 1, 2016

    @NelleV
    Member

    We brainstormed today to find the color names of all possible colors in the vega cycles. We aimed at having only one namespace, and here is what we came up with.
    I think we've nailed it down for category 10 and 20

  17. OceanWolf commented on Nov 2, 2016

    @OceanWolf
    Member

    @tacaswell Any word back from Tableau? Did you just try their main contact, or did you also try some of the specific people in the company, like the person who wrote the blog post cited above for how they devised their new colour scheme.

  18. tacaswell commented on Nov 2, 2016

    @tacaswell
    Member

    I am talking to specific people, I'll update as soon as I know anything new. I am being a bit circumspect as I do not know if everyone on those email threads is ok with them being public.

    Please do not start a second strand of inquiry with them.

  19. OceanWolf commented on Nov 2, 2016

    @OceanWolf
    Member

    Of course not, I wouldn't dream of imposing myself like that.

    It has been two weeks though so I wondered if anything had come of it. I really love the colour scheme, especially for matplotlib and to come clean I have some public projects which I want to use it on ASAP, so I would like the all clear.

    P.S. I should really try and come onto the Skype meetings. I shall try and free myself up to do so.

  20. QuLogic commented on Nov 10, 2016

    @QuLogic
    Member

    I like most of those colour names and agree with most of them. Category 10 and 20 look good, as does 20c, generally.

    For 20b, it would be nice if all the colours did not correspond with the main 10 colours. That would emphasize that they are in a different set without having to modify the prefix explicitly. The red and pink in 20b don't really match with 10's red and pink, so I think that's also a good reason not to call them that as well. Using magenta for 20b's pink seems reasonable, and for 20b's red, maybe coral or salmon (but definitely not pink).

    Also, there should probably be a grey alias for the gray.

  21. modified the milestones: , on Nov 10, 2016
  22. endolith commented on Jan 18, 2017

    @endolith
    Contributor

    It would be nice if

    ax.plot(positive_values, c="g")
    ax.plot(negative_values, c="r")
    

    referred to the new MPL 2.0 default green and red, so we could access them as easily as we could before, instead of using meaningless names like "C0" and "C1".

  23. NelleV commented on Jan 18, 2017

    @NelleV
    Member

    Hi @endolith
    You can now refer to the colors as tab:blue, tab:orange etc.

  24. NelleV commented on Jan 18, 2017

    @NelleV
    Member

    I'm closing this issue, but we should probably document the color naming better.

  25. tacaswell commented on Jan 18, 2017

    @tacaswell
    Member

    The nice thing about the 'CN' names is that they will always track your current color cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions