-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Single-character colors do not match long names #17591
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
Comments
😨 I've removed "Good first issue", because IMHO resolving this is not easy:
|
The issue seems to be that the long names are CSS4 colors, which do not match the base (original MATLAB?) colors for c,m, y. |
The values of The single-letter colors are defined at matplotlib/lib/matplotlib/_color_data.py Lines 4 to 13 in 02194b6
matplotlib/lib/matplotlib/_color_data.py Lines 999 to 1147 in 02194b6
While walking through the blame on this I found that in 2016 I tried to change the single-letter names to be hex like the rest of the color definitions and that broke tests so got abandoned. From my attempts to look at the MATLAB docs (which I can only find back to 2015 online) I don't think this is something we inherited from them. I suspect that this "dimming" of the colors was an intentional aesthetic choice, but we would need confirmation from someone who was around back then. |
This decision predates me, I'm afraid (though I remember the discussion in the 2.0 timeframe of how to handle this in a backward compatible way, if at all). Maybe @efiring knows? |
I think we did inherit the single-letter colors from Matlab. I suspect JDH did this in the very beginning. In early days of both Matlab and mpl, they were the most commonly used colors, by far, forming the default color cycle. There was never any intention that they correspond to colors from some extensive set; they are obviously very simple modifications of RGBCMYK extremes. The modifications are to make them work better. The clearest example of this 'y'. It is much more visible than "yellow". As a color for a line, "yellow" is unusable. |
Wherever the docs has "one of {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}, they are the single character short-hand notations for blue, green, red, cyan, magenta, yellow, black, and white." it could be modified, "...notations for shades of blue...and white, respectively. The particular shades were chosen early in the development of Matplotlib to be suitable for lines against typical backgrounds." The hope here is that the "shades of" phrasing would help reduce any expectation that 'y' should be the same as "yellow". This expectation should already be somewhat reduced by the current phrasing, in which 'y' is in quotes but yellow is not. The former is a name, the latter is generic. |
I just remembered there are multiple locations of this, and #17665 only updated one of them. There's also:
|
A suggestion might be to have long names for these shades so they aren’t ambiguous. Ie mpl-yellow ? |
I don't think we need yet another set of names. The single-letter characters won't go away by introducing corresponding long names. They don't get less ambigous as well: You could only make the connection 'y' -> 'mpl-yellow' in the docs, but that's not better than directly explaining 'y' is a shade of yellow, in fact you still would have to do that. |
Bug report
Bug summary
According to our docs:
Code for reproduction
Actual outcome
Expected outcome
cyan/c, magenta/m, yellow/y should match each other. I don't think we can change these unless we do a 4 release, so I've labelled this as a documentation fix.
Matplotlib version
print(matplotlib.get_backend())
): TkaggThe text was updated successfully, but these errors were encountered: