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

Skip to content

Commit 34bebf9

Browse files
story645meeseeksmachine
authored andcommitted
Backport PR #26569: refactor: constant "ncols" to variables
1 parent 3f7c3d3 commit 34bebf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/color/named_colors.py

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

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

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

0 commit comments

Comments
 (0)