Skip to content

Enh color names #7639

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

Merged
merged 2 commits into from
Jan 16, 2017
Merged

Enh color names #7639

merged 2 commits into from
Jan 16, 2017

Conversation

tacaswell
Copy link
Member

@tacaswell tacaswell commented Dec 18, 2016

This supersedes https://github.com/matplotlib/matplotlib/pull/7343/files

This is the result of an email conversation with Maureen Stone from Tableau.

We still need a link target for the default style changes to tableau.

The naming prefix 'T10' might need a bit more thought as these colors are actually from an older version of Tableau. They have since updated their colors and we should not name our selves into a corner.

@trpham would you be offended if I squashed your commits into 1?

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Dec 18, 2016
@QuLogic
Copy link
Member

QuLogic commented Dec 18, 2016

Still hoping for a 'grey' variant; not sure what to do about the prefix.

<https://github.com/vega/vega/wiki/Scales#scale-range-literals>`__ and
`d3
<https://github.com/d3/d3-3.x-api-reference/blob/master/Ordinal-Scales.md#category10>`__
originally developed at Tableau.
Copy link
Member

Choose a reason for hiding this comment

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

Add link here to the Tableau blog post describing their development?

Copy link
Member Author

Choose a reason for hiding this comment

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

I offered to let Tableau pick where this link goes, still waiting to hear back from them.

Copy link

Choose a reason for hiding this comment

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

Will work on getting you that link soon.

@NelleV
Copy link
Member

NelleV commented Dec 19, 2016

If we go with T10, it implies that we will either have another namespace for the vega 20 colorscheme, or that we won't add those colors.
I'd rather go with the prefix tableau.

@NelleV
Copy link
Member

NelleV commented Dec 19, 2016

This is set to the milestone 2.0. Is that on purpose?
If so, do you mind if I also work on this to get this out of the door ASAP?

@tacaswell
Copy link
Member Author

Yes, milestone is intentional.

I would have claimed this is low risk, but I seem to have broken everything...

@NelleV
Copy link
Member

NelleV commented Dec 19, 2016

It is because the color name cannot contain capital letters with our current code.

@NelleV
Copy link
Member

NelleV commented Dec 19, 2016

(culprit being colors.py l.156, that checks that the lower case of the colorname provided is in a dictionnary).

@mcstone
Copy link

mcstone commented Dec 21, 2016

Just confirming that we at Tableau are quite happy to have you folks include any of our colors as long as they are properly credited (using tableau as the prefix would make that clear, of course, though it is a bit long). The Classic Tableau 10 and 20 have been in use for a while, are the ones currently under discussion. But, I have a new set of default colors that got designed according to this article, as well as many more palettes.

@NelleV
Copy link
Member

NelleV commented Dec 21, 2016

@tacaswell should we change the prefix to tableau ? it is longer to type, but I think it is worth having an explicit name (T10 is a bit obscure). It also allows us to have only one namespace for the 10 and 20 color schemes and in addition fixes the capitalization issue.

@NelleV NelleV self-assigned this Dec 21, 2016
@mcstone
Copy link

mcstone commented Dec 22, 2016

Another prefix to consider is tc (for Tableau Color). Putting the explanation in a comment next to the definition would both provide the mnemonic and give credit.

@NelleV
Copy link
Member

NelleV commented Dec 22, 2016

I still prefer the explicit name "tableau". It is longer to type, but easier to remember.
(I think I am going to loose this battle :p)

@@ -32,8 +32,13 @@ Colors in default property cycle
--------------------------------

The colors in the default property cycle have been changed from
``['b', 'g', 'r', 'c', 'm', 'y', 'k']`` to the `Vega category10 palette
<https://github.com/vega/vega/wiki/Scales#scale-range-literals>`__
``['b', 'g', 'r', 'c', 'm', 'y', 'k']`` to the ``__ to the category10
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 there is a problem here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I swear I know how to delete text....

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.

Typos.

* one of ``{'tc:blue', 'tc:orange', 'tc:green',
'tc:red', 'tc:purple', 'tc:brown', 'tc:pink',
'tc:gray', 'tc:olive', 'tc:cyan'}`` which are the Tableau Colors from the
'T10' categorical palate (which is the default color cycle).
Copy link
Member

Choose a reason for hiding this comment

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

palette

``['b', 'g', 'r', 'c', 'm', 'y', 'k']`` to the `Vega category10 palette
<https://github.com/vega/vega/wiki/Scales#scale-range-literals>`__
``['b', 'g', 'r', 'c', 'm', 'y', 'k']`` to the category10
color palete used by `Vega
Copy link
Member

Choose a reason for hiding this comment

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

palette

@NelleV
Copy link
Member

NelleV commented Dec 30, 2016

@tacaswell What are the next steps on this PR? I don't think we quite reached a consensus on the color palette namespace.

@stonebig
Copy link
Contributor

stonebig commented Jan 5, 2017

is this the last thing blocking Matplotlib-2.0 ? could it be postponed to 2.0.1 ? (looks non critical)

@tacaswell
Copy link
Member Author

color names are part of the API.

@dopplershift
Copy link
Contributor

👍 to tc prefix--tableau is a nightmare for spelling with our predominantly english-speaking audience.

@codecov-io
Copy link

codecov-io commented Jan 10, 2017

Current coverage is 62.10% (diff: 100%)

Merging #7639 into master will increase coverage by <.01%

@@             master      #7639   diff @@
==========================================
  Files           174        174          
  Lines         56051      56057     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          34808      34814     +6   
  Misses        21243      21243          
  Partials          0          0          

Powered by Codecov. Last update 3b9a92d...2810da3

@anntzer
Copy link
Contributor

anntzer commented Jan 10, 2017

+1 for tc as well.

Copy link
Member

@phobson phobson left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I can't for the life of me figure out why the coverage dropped so much.

@tacaswell
Copy link
Member Author

@phobson the whole coverage report looks off, it says this PR adds 65 files.

@NelleV
Copy link
Member

NelleV commented Jan 13, 2017

I still don't like "tc" as a prefix. It is very obscure. Someone suggested to me "tab", as it is both short, and avoids the "eau" that english speakers struggle with remembering.

Are we interested in exploring other possible prefixes?

@NelleV
Copy link
Member

NelleV commented Jan 13, 2017

(Else this looks ready to be merged)

@dopplershift
Copy link
Contributor

"tab" works for me.

@phobson
Copy link
Member

phobson commented Jan 13, 2017

@NelleV I think this ship has sailed :/.

My personal preference would be tableau, but given that the palette's designer has blessed tc, that's probably the best option.

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.

Still want a 'grey', but this really should move along...

@anntzer
Copy link
Contributor

anntzer commented Jan 16, 2017

@QuLogic @tacaswell re: grey
Isn't this just a matter of adding it in the T10_COLORS dictionary? If so I'd +1 adding it right now...

@tacaswell
Copy link
Member Author

I am wary of adding extra colors given that we are adopting an existing palette.

We already have 'grey' and 'gray' the un-prefixed colors and floats as strings get mapped to shades of gray.

import matplotlib.colors as mc
print(mc.to_hex(mc.to_rgb('gray'))) 
# '#808080'

@QuLogic
Copy link
Member

QuLogic commented Jan 16, 2017

They are, as with the unprefixed colours, expected to be the same colour, not some new value.

@QuLogic
Copy link
Member

QuLogic commented Jan 16, 2017

And in the unprefixed set, we have darkgray/darkgrey, darkslategray/darkslategrey, dimgray/dimgrey, gray/grey, lightgray/lightgrey, lightslategray/lightslategrey, slategray/slategrey with every pair equal to each other, so I don't see why this new palette can't have the same aliasing.

Interestingly, the xkcd palette only spells it 'grey'.

@tacaswell
Copy link
Member Author

@QuLogic Sorry, completely missed that we already had 'tc:gray' and was responding to something un-related to what you were asking 🐑

My only concern about including two spellings of 'gray' in the palette is that users may want to use list(matplotlib.colors.T10_COLORS.items()) as a color cycle. Of the dictionaries we currently have, it is the only one small enough to usable for that, so this a completely made up use case, but one I could see growing in the future.

@anntzer
Copy link
Contributor

anntzer commented Jan 16, 2017

That would require (in practice) the dict being an OrderedDict, which may not be a bad idea in itself...

@tacaswell
Copy link
Member Author

@anntzer That is also a good point and idea!

@anntzer
Copy link
Contributor

anntzer commented Jan 16, 2017

(but then you need to know where to put the other spelling of grey/gray in the ordereddict)

@tacaswell
Copy link
Member Author

Looking at the work you did in colors.py with the _colors_full_mapping we can do the gray/grey normalization there and leave TABLEAU_COLORS and XKCD_COLORS spelled as the source material spells them. I am not 100% that the spelling it tableau is 'cannonical', might want to normalize it to 'grey' to match xkcd (which makes the duplication code in colors.py a bit more uniform).

@tacaswell
Copy link
Member Author

To try and summarize all of the prefix discussions:

  • tableau
    • pro: very explicit
    • con: long, any future varients would be even longer
    • con: anglophiles have a hard time spelling it
  • tc
    • pro: short
    • pro: suggested by @mcstone from tableau
    • con: some what obscure to source of naming
    • con: 'c' is redundant as we all know we are talking about colors
    • con(?): my initials
  • t
    • same as tc, but even shorter!
  • tab
    • pro: short
    • pro: much less obscure than 'tc'
    • con: collision with head namespace of the tab key? (that is the best I can come up with)

and I think I have written my self into preferring 'tab'

@dopplershift
Copy link
Contributor

Because of the initials aspect, at the very minimum we need a comment saying explicitly what tc stands for.

@efiring
Copy link
Member

efiring commented Jan 16, 2017 via email

trpham and others added 2 commits January 16, 2017 15:12
 - change naming to tab
 - credit Tableau for developing the colors
 - support both spellings of grey an Tableau&xkcd colors
 - add tests of grey/gray equivalence and tableau order
 - use more explicit internal names + add comment
@NelleV
Copy link
Member

NelleV commented Jan 16, 2017

LGTM 👍

@efiring efiring merged commit 7555a7a into matplotlib:master Jan 16, 2017
@tacaswell tacaswell deleted the enh_color_names branch January 16, 2017 20:32
tacaswell pushed a commit that referenced this pull request Jan 16, 2017
@tacaswell
Copy link
Member Author

backported to v2.x as 4e1df0b

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.