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

Skip to content

Commit 03fa6ea

Browse files
authored
Merge pull request #26569 from AmirAflak/named_colors
refactor: constant "ncols" to variables
2 parents 813e41a + eb68989 commit 03fa6ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

galleries/examples/color/named_colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def plot_colortable(colors, *, ncols=4, sort_colors=True):
4242
n = len(names)
4343
nrows = math.ceil(n / ncols)
4444

45-
width = cell_width * 4 + 2 * margin
45+
width = cell_width * ncols + 2 * margin
4646
height = cell_height * nrows + 2 * margin
4747
dpi = 72
4848

4949
fig, ax = plt.subplots(figsize=(width / dpi, height / dpi), dpi=dpi)
5050
fig.subplots_adjust(margin/width, margin/height,
5151
(width-margin)/width, (height-margin)/height)
52-
ax.set_xlim(0, cell_width * 4)
52+
ax.set_xlim(0, cell_width * ncols)
5353
ax.set_ylim(cell_height * (nrows-0.5), -cell_height/2.)
5454
ax.yaxis.set_visible(False)
5555
ax.xaxis.set_visible(False)

0 commit comments

Comments
 (0)