-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add solarized palette as named colors #11927
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
Add solarized palette as named colors #11927
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
There are a few minor style issues. Otherwise good to go.
examples/color/named_colors.py
Outdated
@@ -16,7 +16,8 @@ | |||
from matplotlib import colors as mcolors | |||
|
|||
|
|||
colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS) | |||
colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS, | |||
**mcolors.SOLARIZED_COLORS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the continued line with the inside I’d the parentheses, I.e. remove two spaces.
lib/matplotlib/_color_data.py
Outdated
# Copyright (c) 2011 Ethan Schoonover | ||
SOLARIZED_COLORS = { | ||
'solarized-base03': '#002b36', | ||
'solarized-base02': '#073642', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the color values with the color values of the CSS colors above.
lib/matplotlib/colors.py
Outdated
@@ -50,7 +50,8 @@ | |||
|
|||
import numpy as np | |||
import matplotlib.cbook as cbook | |||
from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, XKCD_COLORS | |||
from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For multi-line imports we prefer enclosing in brackets over line-continuation characters, i.e.
from ._color_data import (BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS,
XKCD_COLORS, SOLARIZED_COLORS)
lib/matplotlib/_color_data.py
Outdated
# License: https://github.com/altercation/solarized/blob/master/LICENSE | ||
# Copyright (c) 2011 Ethan Schoonover | ||
SOLARIZED_COLORS = { | ||
'solarized-base03': '#002b36', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The namespacing method we use (cf. xkcd, tab) is "solarized:base03" (colon), not "solarized-base03" (dash).
Anyone can dismiss this once handled.
This largely seems good to me, but doesnt' seem an optimal way to display these. Also, Tableau colors are not displayed. Maybe each color group should get its own subsection? |
Display Tableau colors, and now each color group should get its own figure
@jklymak Have updated the named colors example to address your suggestions. Let me know if it's OK! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of adding separate sections for the different color groups is great. However the current implementation is not sufficient IMHO. I expect all texts to be of the same font size. Also the color patches should all be of the same size and at best even be aligned across the groups.
You may improve this here or split it into another PR, if that's easier.
Noted, look our for a new PR here! |
It's really a bit difficult to exactly control sizes and positions in such a plot. Try this for the color table:
|
OK, added a few tweaks to your update as well. |
Tangent: Adding the Solarized palette led me to discover that Tableau updated their color palette in 2016. Not sure if it's worth it to update the colors? (Not in this PR, of course.) I myself don't personally use Tableau or its palette, so the benefits are unclear to me. |
The list of which options there are to specify colors in matplotlib appears in three places:
Ultimately one would need to update all three tables with the new Additional question: Do the "Accent colors" qualify to create a new listed (discrete) colormap from them, similar to how "tableau" colors are in the "tab10" colormap? |
Sorting of the named colors example handled separately.
@josesho still interested in adding solarized colors? The color sorting has been handled separately in #12209. So this PR can be simplified again. Please note also, that we do not write to |
Relevant here: #12009 (comment). Essentially adding new named colors has been discussed in a monday's call and the overall opinion (though not shared by everyone) was not to add too many of them. So I'm not sure in how far this applies here. |
I'll have a look at #12209 and modify this PR accordingly. 👌 |
ping @josesho: Pushing to 3.2, but feel free to update when you get a chance... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in #12009, more and more "named colors" has to stop somewhere. The idea behind this PR is great, but we need a way to organize these custom lists better....
Been snowed under with work but let me get back to this and see what I need to do! |
Sorry I should have been clearer; we need some sort of way to manage these lists of named colors. Otherwise we will have hundreds of them. |
More or less in the same way as for the colormap discussion in some other thread, this could basically be implemented as a third-party package. In fact a quick googling shows that there's already https://pypi.org/project/pygments-solarized/ which exposes the desired colors in
which is not much worse than |
@josesho Could you put a note about this in the color docs? |
PR Summary
PR Checklist