Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ def from_list(name, colors, N=256, gamma=1.0, *, bad=None, under=None, over=None
except Exception as e2:
raise e2 from e
vals = np.asarray(_vals)
if np.min(vals) < 0 or np.max(vals) > 1 or np.any(np.diff(vals) <= 0):
if np.min(vals) < 0 or np.max(vals) > 1 or np.any(np.diff(vals) < 0):
raise ValueError(
"the values passed in the (value, color) pairs "
"must increase monotonically from 0 to 1."
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,13 @@ def test_LinearSegmentedColormap_from_list_value_color_tuple():
)


def test_LinearSegmentedColormap_from_list_repeat_values():
# Smoke test that we can pass repeated values to make a solid band of color
# followed by a linear ramp.
value_color_tuples = [(0, "red"), (0.6, "red"), (0.6, "blue"), (1, "green")]
mcolors.LinearSegmentedColormap.from_list("lsc", value_color_tuples, N=11)


@image_comparison(['test_norm_abc.png'], remove_text=True, style='_classic_test',
tol=0 if platform.machine() == 'x86_64' else 0.05)
def test_norm_abc():
Expand Down
Loading