Skip to content

Commit 1e03157

Browse files
author
ojeda-e
committed
Added markevery_prop_cycle test.
1 parent 2ccc67f commit 1e03157

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/matplotlib/tests/test_lines.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
from matplotlib.testing.decorators import image_comparison, check_figures_equal
2121

2222

23+
@pytest.fixture
24+
def cases():
25+
"""Define a list of markevery cases to plot."""
26+
cases = [None, 8, (30, 8), [16, 24, 30], [0, -1],
27+
slice(100, 200, 3), 0.1, 0.3, 1.5,
28+
(0.0, 0.1), (0.45, 0.1)]
29+
return cases
30+
31+
2332
def test_segment_hits():
2433
"""Test a problematic case."""
2534
cx, cy = 553, 902
@@ -343,3 +352,25 @@ def test_input_copy(fig_test, fig_ref):
343352
# Trigger cache invalidation
344353
l.set_drawstyle("steps")
345354
fig_ref.add_subplot().plot([0, 2, 4], [0, 2, 4], ".-", drawstyle="steps")
355+
356+
357+
@check_figures_equal(extensions=["png"])
358+
def test_markevery_prop_cycle(fig_test, fig_ref, cases):
359+
360+
cmap = plt.get_cmap('jet')
361+
colors = cmap(np.linspace(0.2, 0.8, 100))[:len(cases)]
362+
363+
x = np.linspace(0, 2 * np.pi)
364+
offsets = np.linspace(0, 2 * np.pi, 11, endpoint=False)
365+
yy = np.transpose([np.sin(x + phi) for phi in offsets])
366+
367+
axs = fig_ref.add_axes([0.1, 0.1, 0.6, 0.75])
368+
for i in range(len(cases)):
369+
axs.plot(yy[:, i], markevery=cases[i], c=colors[i])
370+
371+
matplotlib.rcParams['axes.prop_cycle'] = cycler(markevery=cases,
372+
color=colors)
373+
374+
ax = fig_test.add_axes([0.1, 0.1, 0.6, 0.75])
375+
for i in range(len(cases)):
376+
ax.plot(yy[:, i])

0 commit comments

Comments
 (0)