|
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 | | - |
32 | 23 | def test_segment_hits(): |
33 | 24 | """Test a problematic case.""" |
34 | 25 | cx, cy = 553, 902 |
@@ -355,22 +346,26 @@ def test_input_copy(fig_test, fig_ref): |
355 | 346 |
|
356 | 347 |
|
357 | 348 | @check_figures_equal(extensions=["png"]) |
358 | | -def test_markevery_prop_cycle(fig_test, fig_ref, cases): |
| 349 | +def test_markevery_prop_cycle(fig_test, fig_ref): |
| 350 | + """Test that we can set markevery prop_cycle.""" |
| 351 | + cases = [None, 8, (30, 8), [16, 24, 30], [0, -1], |
| 352 | + slice(100, 200, 3), 0.1, 0.3, 1.5, |
| 353 | + (0.0, 0.1), (0.45, 0.1)] |
359 | 354 |
|
360 | 355 | cmap = plt.get_cmap('jet') |
361 | 356 | colors = cmap(np.linspace(0.2, 0.8, len(cases))) |
362 | 357 |
|
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]) |
| 358 | + x = np.linspace(-1, 1) |
| 359 | + y = 5 * x**2 |
366 | 360 |
|
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]) |
| 361 | + axs = fig_ref.add_subplot() |
| 362 | + for i, markevery in enumerate(cases): |
| 363 | + axs.plot(y - i, 'o-', markevery=markevery, color=colors[i]) |
370 | 364 |
|
371 | 365 | matplotlib.rcParams['axes.prop_cycle'] = cycler(markevery=cases, |
372 | 366 | color=colors) |
373 | 367 |
|
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]) |
| 368 | + ax = fig_test.add_subplot() |
| 369 | + for i, _ in enumerate(cases): |
| 370 | + ax.plot(y - i, 'o-') |
| 371 | + |
0 commit comments