Skip to content

Commit

Permalink
Backport PR matplotlib#26569: refactor: constant "ncols" to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
story645 authored and meeseeksmachine committed Aug 21, 2023
1 parent 3f7c3d3 commit 34bebf9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 34bebf9

Please sign in to comment.