Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename 'open' category --> 'opencolor'
  • Loading branch information
lukelbd committed Jan 7, 2020
commit f0824586d4bcc1c9634559c3289f3d2a4d9d466e
File renamed without changes.
17 changes: 10 additions & 7 deletions proplot/styletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3022,23 +3022,26 @@ def register_colors(nmax=np.inf):
if i == 0:
paths = [ # be explicit because categories matter!
os.path.join(path, base)
for base in ('xkcd.txt', 'crayola.txt', 'open.txt')
for base in ('xkcd.txt', 'crayola.txt', 'opencolor.txt')
]
else:
paths = sorted(glob.glob(os.path.join(path, '*.txt')))
for file in paths:
cat, _ = os.path.splitext(os.path.basename(file))
with open(file, 'r') as f:
pairs = [tuple(item.strip() for item in line.split(':'))
for line in f.readlines() if line.strip()]
pairs = [
tuple(item.strip() for item in line.split(':'))
for line in f.readlines()
if line.strip() and line.strip()[0] != '#'
]
if not all(len(pair) == 2 for pair in pairs):
raise RuntimeError(
f'Invalid color names file {file!r}. '
f'Every line must be formatted as "name: color".'
)

# Categories for which we add *all* colors
if cat == 'open' or i == 1:
if cat == 'opencolor' or i == 1:
dict_ = {name: color for name, color in pairs}
mcolors.colorConverter.colors.update(dict_)
colors[cat] = sorted(dict_)
Expand Down Expand Up @@ -3430,8 +3433,8 @@ def _color_filter(i, hcl): # noqa: E306
figs = []
from . import subplots
for cats in (
('open',),
tuple(name for name in colors if name not in ('css', 'open'))
('opencolor',),
tuple(name for name in colors if name not in ('css', 'opencolor'))
):
# Dictionary of colors for that category
data = {}
Expand All @@ -3441,7 +3444,7 @@ def _color_filter(i, hcl): # noqa: E306

# Group colors together by discrete range of hue, then sort by value
# For opencolors this is not necessary
if cats == ('open',):
if cats == ('opencolor',):
wscale = 0.5
swatch = 1.5
nrows, ncols = 10, len(COLORS_OPEN) # rows and columns
Expand Down