8000 Merge pull request #11658 from joelostblom/sort-named-colors-vertically · matplotlib/matplotlib@c1d086f · GitHub
[go: up one dir, main page]

Skip to content

Commit c1d086f

Browse files
authored
Merge pull request #11658 from joelostblom/sort-named-colors-vertically
Sort named colors example vertically for easier comparison of similar colors
2 parents 721fc04 + cc0df1f commit c1d086f

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,25 +25,25 @@
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=(9, 8))
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)
4343
xf_line = w * (col + 0.25)
4444
xi_text = w * (col + 0.3)
4545

46-
ax.text(xi_text, y, name, fontsize=(h * 0.8),
46+
ax.text(xi_text, y, name, fontsize=(h * 0.5),
4747
horizontalalignment='left',
4848
verticalalignment='center')
4949

0 commit comments

Comments
 (0)
0