8000 Sort named colors vertically for easier comparison of similar colors · matplotlib/matplotlib@99b2957 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99b2957

Browse files
committed
Sort named colors vertically for easier comparison of similar colors
1 parent 721fc04 commit 99b2957

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/color/named_colors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
n = len(sorted_names)
2727
ncols = 4
28-
nrows = n // ncols + 1
28+
nrows = n // ncols
2929

30-
fig, ax = plt.subplots(figsize=(8, 5))
30+
fig, ax = plt.subplots(figsize=(12, 10))
3131

3232
# Get height and width
3333
X, Y = fig.get_dpi() * fig.get_size_inches()
3434
h = Y / (nrows + 1)
3535
w = X / ncols
3636

3737
for i, name in enumerate(sorted_names):
38-
col = i % ncols
39-
row = i // ncols
38+
row = i % nrows
39+
col = i // nrows
4040
y = Y - (row * h) - h
4141

4242
xi_line = w * (col + 0.05)
@@ -48,7 +48,7 @@
4848
verticalalignment='center')
4949

5050
ax.hlines(y + h * 0.1, xi_line, xf_line,
51-
color=colors[name], linewidth=(h * 0.6))
51+
color=colors[name], linewidth=(h * 0.8))
5252

5353
ax.set_xlim(0, X)
5454
ax.set_ylim(0, Y)

0 commit comments

Comments
 (0)
0