|
20 | 20 | from matplotlib.testing.decorators import image_comparison, check_figures_equal |
21 | 21 |
|
22 | 22 |
|
| 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 | + |
23 | 32 | def test_segment_hits(): |
24 | 33 | """Test a problematic case.""" |
25 | 34 | cx, cy = 553, 902 |
@@ -343,3 +352,25 @@ def test_input_copy(fig_test, fig_ref): |
343 | 352 | # Trigger cache invalidation |
344 | 353 | l.set_drawstyle("steps") |
345 | 354 | 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