From 34bebf9d700e48a875045bd627b9e5802bb9f0a0 Mon Sep 17 00:00:00 2001 From: hannah Date: Mon, 21 Aug 2023 19:07:54 -0400 Subject: [PATCH] Backport PR #26569: refactor: constant "ncols" to variables --- examples/color/named_colors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/color/named_colors.py b/examples/color/named_colors.py index 5a8e3667689a..7f7b4fc6db3c 100644 --- a/examples/color/named_colors.py +++ b/examples/color/named_colors.py @@ -41,14 +41,14 @@ def plot_colortable(colors, *, ncols=4, sort_colors=True): n = len(names) nrows = math.ceil(n / ncols) - width = cell_width * 4 + 2 * margin + width = cell_width * ncols + 2 * margin height = cell_height * nrows + 2 * margin dpi = 72 fig, ax = plt.subplots(figsize=(width / dpi, height / dpi), dpi=dpi) fig.subplots_adjust(margin/width, margin/height, (width-margin)/width, (height-margin)/height) - ax.set_xlim(0, cell_width * 4) + ax.set_xlim(0, cell_width * ncols) ax.set_ylim(cell_height * (nrows-0.5), -cell_height/2.) ax.yaxis.set_visible(False) ax.xaxis.set_visible(False)