-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Adding names to the color in the new Vega10 color cycle #7343
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
Changes from 1 commit
f819a44
9d6247f
56eed35
ded8d66
a270ac8
8950350
5ae9cba
8b3b971
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,23 @@ | |
'w': (1, 1, 1)} | ||
|
||
|
||
VEGA10_COLORS = { | ||
'blue': '#1f77b4', | ||
'orange': '#ff7f0e', | ||
'green': '#2ca02c', | ||
'red': '#d62728', | ||
'purple': '#9467bd', | ||
'brown': '#8c564b', | ||
'pink': '#e377c2', | ||
'gray': '#7f7f7f', | ||
'olive': '#bcbd22', | ||
'cyan': '#17becf'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pep8 might want that closing brace to be on the next line. Not sure though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't. That line is fine pep8-wise. |
||
|
||
|
||
# Normalize name to "vega:<name>" to avoid name collisions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we decided on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there was a consensus on that (and I'm not sure it's necessary either.) |
||
VEGA10_COLORS = {'vega:' + name: value for name, value in VEGA10_COLORS.items()} | ||
8000
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That line is slightly too long for pep8 (1 character too long). The tests are failing because of this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NelleV I did notice that, but it's exactly 80 characters, and I thought leave it like that way is cleaner. Let's me fix it. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe change this dictionary comprehension to a for loop for better readability? It seems like too much is being done in one statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as comprehensions go, this one is pretty simple; I don't think it needs to be rewritten. At most, add a break before |
||
|
||
# This mapping of color names -> hex values is taken from | ||
# a survey run by Randel Monroe see: | ||
# http://blog.xkcd.com/2010/05/03/color-survey-results/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ | |
|
||
import numpy as np | ||
import matplotlib.cbook as cbook | ||
from ._color_data import BASE_COLORS, CSS4_COLORS, XKCD_COLORS | ||
from ._color_data import BASE_COLORS, VEGA10_COLORS, CSS4_COLORS, XKCD_COLORS | ||
|
||
|
||
class _ColorMapping(dict): | ||
|
@@ -86,6 +86,7 @@ def __delitem__(self, key, value): | |
# Set by reverse priority order. | ||
_colors_full_map.update(XKCD_COLORS) | ||
_colors_full_map.update(CSS4_COLORS) | ||
_colors_full_map.update(VEGA10_COLORS) | ||
_colors_full_map.update(BASE_COLORS) | ||
_colors_full_map = _ColorMapping(_colors_full_map) | ||
|
||
|
@@ -250,7 +251,7 @@ def to_hex(c, keep_alpha=False): | |
### Backwards-compatible color-conversion API | ||
|
||
cnames = CSS4_COLORS | ||
COLOR_NAMES = {'xkcd': XKCD_COLORS, 'css4': CSS4_COLORS} | ||
COLOR_NAMES = {'xkcd': XKCD_COLORS, 'css4': CSS4_COLORS, 'vega': VEGA10_COLORS} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 10 is missing in the name: it should be |
||
hexColorPattern = re.compile("\A#[a-fA-F0-9]{6}\Z") | ||
|
||
|
||
|
@@ -401,7 +402,7 @@ class Colormap(object): | |
|
||
""" | ||
def __init__(self, name, N=256): | ||
r""" | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
Parameters | ||
---------- | ||
name : str | ||
|
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 thinking about documenting this change! That's a really important part of making new features accessible to users.
I think you should add the "vega" prefix to be more specific.
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.
Fixed