Skip to content

Commit cff3381

Browse files
authored
ListedColormap: don't pass n colors (#145)
1 parent 3f71c4e commit cff3381

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

mplotutils/_colormaps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _color_palette(cmap, n_colors):
5555
colors_i = np.linspace(0, 1.0, n_colors)
5656
if isinstance(cmap, (list, tuple)):
5757
# we have a list of colors
58-
cmap = ListedColormap(cmap, N=n_colors)
58+
cmap = ListedColormap(cmap)
5959
pal = cmap(colors_i)
6060
elif isinstance(cmap, str):
6161
# we have some sort of named palette
@@ -71,7 +71,7 @@ def _color_palette(cmap, n_colors):
7171
pal = color_palette(cmap, n_colors=n_colors)
7272
except (ValueError, ImportError):
7373
# or maybe we just got a single color as a string
74-
cmap = ListedColormap([cmap], N=n_colors)
74+
cmap = ListedColormap([cmap] * n_colors)
7575
pal = cmap(colors_i)
7676
else:
7777
# cmap better be a LinearSegmentedColormap (e.g. viridis)

mplotutils/tests/test_hatch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def test_hatch_linewidth_mpl_lt_310(function):
151151

152152

153153
@requires_mpl_ge_310
154+
@pytest.mark.filterwarnings("ignore:Passing 'N' to ListedColormap is deprecated")
154155
@pytest.mark.parametrize("function", HATCH_FUNCTIONS)
155156
def test_hatch_linewidth_mpl_ge_310(function):
156157

0 commit comments

Comments
 (0)