Skip to content

Commit 9867b44

Browse files
jklymakMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #11658: Sort named colors example vertically for easier comparison of similar colors
1 parent 85b4eb8 commit 9867b44

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/color/named_colors.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@
2626

2727
n = len(sorted_names)
2828
ncols = 4
29-
nrows = n // ncols + 1
29+
nrows = n // ncols
3030

31-
fig, ax = plt.subplots(figsize=(8, 5))
31+
fig, ax = plt.subplots(figsize=(9, 8))
3232

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

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

4343
xi_line = w * (col + 0.05)
4444
xf_line = w * (col + 0.25)
4545
xi_text = w * (col + 0.3)
4646

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

0 commit comments

Comments
 (0)