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

Skip to content

Commit 800d4ad

Browse files
committed
DOC: Ensure named colours are sorted by name too.
This keeps aliased colours like gray/grey or fuschia/magenta in the same order every time.
1 parent 1856ca3 commit 800d4ad

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

examples/color/named_colors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
sat = [color[1] for color in hsv]
3434
val = [color[2] for color in hsv]
3535

36-
# Sort by hue, saturation and value.
37-
ind = np.lexsort((val, sat, hue))
36+
# Get the color names by themselves.
37+
names = [color[0] for color in colors_]
38+
39+
# Sort by hue, saturation, value and name.
40+
ind = np.lexsort((names, val, sat, hue))
3841
sorted_colors = [colors_[i] for i in ind]
3942

4043
n = len(sorted_colors)

0 commit comments

Comments
 (0)