Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2543f6

Browse files
committed
MNT: add xkcd prefix + switch priority order
- prefer the CSS4 str -> hex values because they are the 'standard'. The xkcd colors might be 'better', but we are not the right place to lead that change. If users use CSS/HTML/X11 color in mpl they should expect it to match the same color set in html for embedding mpl figures into websites and such. - Provide entries in XKCD dict of all names (with and with out spaces) prefixed with XKCD. Thus to get XKCD's version of blue use `color='xkcdblue'
1 parent bda202b commit b2543f6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/matplotlib/_color_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,14 @@
961961
'green': '#15b01a',
962962
'purple': '#7e1e9c'}
963963

964-
# normalize to names with no spaces
964+
# normalize to names with no spaces and provide versions with XKCD
965+
# prefix.
965966
for k in list(XKCD_COLORS):
967+
XKCD_COLORS['XKCD'+k] = XKCD_COLORS[k]
966968
_k = k.replace(' ', '')
967969
if _k != k:
968970
XKCD_COLORS[_k] = XKCD_COLORS[k]
971+
XKCD_COLORS['XKCD'+_k] = XKCD_COLORS[k]
969972

970973

971974
# https://drafts.csswg.org/css-color-4/#named-colors

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ColorConverter(object):
115115
'w': '#ffffff'}
116116

117117
cache = {}
118-
CN_LOOKUPS = [colors, ] + [COLOR_NAMES[k] for k in ['xkcd', 'css4']]
118+
CN_LOOKUPS = [colors, ] + [COLOR_NAMES[k] for k in ['css4', 'xkcd']]
119119

120120
def to_rgb(self, arg):
121121
"""

0 commit comments

Comments
 (0)