Skip to content
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

Use xkcd: prefix to avoid color name clashes. #6390

Merged
merged 2 commits into from May 12, 2016

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 9, 2016

Split out of #6382.

Without the prefix, merging CSS4_COLORS and XKCD_COLORS becomes order-dependent.

It's also unclear why space-less names are needed, but I can put them back if someone feels strongly about it...

Otherwise, merging CSS4_COLORS and XKCD_COLORS becomes order-dependent.

It's also unclear why space-less names are needed, but I can put them
back if someone feels strongly about it...
@tacaswell tacaswell added this to the 2.0 (style change major release) milestone May 9, 2016

All string specifications of color are case-insensitive.

Internally, mpl is moving to storing all colors as RGBA float quadruples.

Name clash between CSS4/X11 and XKCD
Copy link
Member

Choose a reason for hiding this comment

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

Please leave this plot.

Copy link
Member

Choose a reason for hiding this comment

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

Even if we are explicitly name-spacing the colors, I think this chart is still interesting to include in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you OK for explicitly namespacing everything then? It'll always be easier to add un-namespaced versions later than removing them...

@tacaswell
Copy link
Member

I am still in favor of leaving both the prefixed and un-prefixed versions. For names that are only in the xkcd name space there is no reason to include the extra 5 characters.

We should also document the names as 'XKCD:...' as I think that is his 'preferred' branding.

@anntzer
Copy link
Contributor Author

anntzer commented May 9, 2016

I can change the prefix to XKCD, no problem there.
The whole point of the PR is so that {**CSS4_COLORS, **XKCD_COLORS} and {**XKCD_COLORS, **CSS4_COLORS} give the same results, and I'm sort of hoping that this can become an "official" namespacing mechanism for named colors (perhaps seaborn can do its color-remapping by putting its colors in the seaborn-{deep,muted,...}:<...> namespace and we can even have a mechanism to change the named colors resolution order, e.g. plt.colors.set_name_resolution_order(["seaborn-deep", "css4", "xkcd"])).

@tacaswell
Copy link
Member

One of the things we decided in the discussion on the pr where the XKCD
colors went in was that we should not change the meaning of the css colors.

On Mon, May 9, 2016, 16:10 Antony Lee notifications@github.com wrote:

I can change the prefix to XKCD, no problem there.
The whole point of the PR is so that {**CSS4_COLORS, **XKCD_COLORS} and {**XKCD_COLORS,
**CSS4_COLORS} give the same results, and I'm sort of hoping that this
can become an "official" namespacing mechanism for named colors (perhaps
seaborn can do its color-remapping by putting its colors in the
seaborn-{deep,muted,...}:<...> namespace and we can even have a mechanism
to change the named colors resolution order, e.g. plt.colors.set_name_resolution_order(["seaborn-deep",
"css4", "xkcd"])).


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#6390 (comment)

@anntzer
Copy link
Contributor Author

anntzer commented May 9, 2016

Then the "base" namespace could cover both the one-letter codes and the CSS4 names?

@tacaswell
Copy link
Member

I am hesitant to combine the single letter colors (which are home grown)
and the css4 colors (which is a published spec) for the sake of keeping the
code tidy (where tidy here is clarity of what things are) rather than a
minimum number of variables.

The other concern is that we can not encode the single letter colors as hex
due to float rounding issues where as the CSS4 colors are defined as RGB
hex values.

On Mon, May 9, 2016 at 4:37 PM Antony Lee notifications@github.com wrote:

Then "base" could cover both the one-letter codes and the CSS4 names?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#6390 (comment)

@anntzer
Copy link
Contributor Author

anntzer commented May 9, 2016

TBH I don't feel strongly about anything here, except that having a name clash by default looks... unappetizing. A namespacing/priority mechanism (say, "base", "css4", "xkcd", "seaborn-<...>") would not, by default, change the meaning of the CSS colors (but it would be possible for the user the change them -- in a more "ordered" manner than seaborn currently changes the base colors.

@anntzer
Copy link
Contributor Author

anntzer commented May 11, 2016

By the way, regarding xkcd vs XKCD: http://xkcd.com/about/

For those of us pedantic enough to want a rule, here it is: The preferred form is "xkcd", all lower-case. In formal contexts where a lowercase word shouldn't start a sentence, "XKCD" is an okay alternative. "Xkcd" is frowned upon.

@tacaswell
Copy link
Member

huh, fair enough re xkcd. Could have sworn I read the opposite....

@@ -563,7 +563,7 @@ def test_xkcd():
mcolors.colorConverter.to_rgb('blue'))
assert x11_blue == '#0000ff'
XKCD_blue = mcolors.rgb2hex(
mcolors.colorConverter.to_rgb('XKCDblue'))
mcolors.colorConverter.to_rgb('xkcd:blue'))
Copy link
Member

Choose a reason for hiding this comment

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

This does read much better.

@tacaswell
Copy link
Member

I am also 👍 on this modulo a few comments.

@anntzer
Copy link
Contributor Author

anntzer commented May 11, 2016

I have no idea what's wrong with this build...

j = 0

for n in sorted(overlap, reverse=True):
for j, n in enumerate(sorted(overlap, reverse=True)):
Copy link
Member

Choose a reason for hiding this comment

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

This means you can also drop the j += 1 below.

@tacaswell
Copy link
Member

That failure was a bug in pyparsing 2.1.2 which just died on import on 3.4, it is fixed multiple ways already.

@efiring Thoughts on this naming change?

I would be fine if this were merged and it was my job to fix that plot (but would not be opposed to @anntzer fixing it 😉 )

@efiring
Copy link
Member

efiring commented May 12, 2016

I like the use of 'xkcd:' as a prefix for all xkcd colors.
I'm confused by the references to "space-stripped" names. The html names are all stripped, but this ugliness is somewhat reduced in http://www.w3schools.com/colors/colors_names.asp by the use of CamelCase. (Leaving out spaces has its advantages, so I'm not complaining about the html names.) The xkcd colors are a mess, with "dark blue" (00035b) and "darkblue" (030764). I suspect whoever thought that was a good idea was high at the time. Overall, the color matching in xkcd is good, but there are too many of them, and too many with revolting names. But we are stuck with that, and I have digressed.

@tacaswell
Copy link
Member

I completely missed that there is both 'dark blue' and 'darkblue'. The downsides of machine learning + crowd sourcing....

@anntzer
Copy link
Contributor Author

anntzer commented May 12, 2016

Here's the offenders:

In [4]: sorted([c for c in XKCD_COLORS if " " in c and c.replace(" ", "") in XKCD_COLORS])
Out[4]: 
['xkcd:aqua marine',
 'xkcd:blue green',
 'xkcd:blue grey',
 'xkcd:dark blue',
 'xkcd:dark green',
 'xkcd:egg shell',
 'xkcd:golden rod',
 'xkcd:green blue',
 'xkcd:grey blue',
 'xkcd:light blue',
 'xkcd:light green',
 'xkcd:orange red',
 'xkcd:terra cotta',
 'xkcd:yellow green']

Anyways, I guess this answers the question...

@tacaswell tacaswell merged commit d03e798 into matplotlib:master May 12, 2016
@tacaswell
Copy link
Member

I will fix that figure my self in a follow on PR

@anntzer anntzer deleted the xkcd-colors-namespace branch May 12, 2016 21:34
tacaswell added a commit that referenced this pull request May 12, 2016
API: Use xkcd: prefix to avoid color name clashes.
@tacaswell
Copy link
Member

backported to 2.x as c2b6769

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.

None yet

4 participants