diff --git a/mplotutils/_colormaps.py b/mplotutils/_colormaps.py index 0c6856a..d29fb64 100644 --- a/mplotutils/_colormaps.py +++ b/mplotutils/_colormaps.py @@ -55,7 +55,7 @@ def _color_palette(cmap, n_colors): colors_i = np.linspace(0, 1.0, n_colors) if isinstance(cmap, (list, tuple)): # we have a list of colors - cmap = ListedColormap(cmap, N=n_colors) + cmap = ListedColormap(cmap) pal = cmap(colors_i) elif isinstance(cmap, str): # we have some sort of named palette @@ -71,7 +71,7 @@ def _color_palette(cmap, n_colors): pal = color_palette(cmap, n_colors=n_colors) except (ValueError, ImportError): # or maybe we just got a single color as a string - cmap = ListedColormap([cmap], N=n_colors) + cmap = ListedColormap([cmap] * n_colors) pal = cmap(colors_i) else: # cmap better be a LinearSegmentedColormap (e.g. viridis) diff --git a/mplotutils/tests/test_hatch.py b/mplotutils/tests/test_hatch.py index a6bb09e..cb41c51 100644 --- a/mplotutils/tests/test_hatch.py +++ b/mplotutils/tests/test_hatch.py @@ -151,6 +151,7 @@ def test_hatch_linewidth_mpl_lt_310(function): @requires_mpl_ge_310 +@pytest.mark.filterwarnings("ignore:Passing 'N' to ListedColormap is deprecated") @pytest.mark.parametrize("function", HATCH_FUNCTIONS) def test_hatch_linewidth_mpl_ge_310(function):