|
6 | 6 |
|
7 | 7 | from matplotlib import pyplot as plt |
8 | 8 | from matplotlib.testing.decorators import image_comparison |
| 9 | +from matplotlib.testing.decorators import check_figures_equal |
9 | 10 |
|
10 | 11 |
|
11 | 12 | def draw_quiver(ax, **kwargs): |
@@ -333,3 +334,53 @@ def test_quiver_setuvc_numbers(): |
333 | 334 |
|
334 | 335 | q = ax.quiver(X, Y, U, V) |
335 | 336 | q.set_UVC(0, 1) |
| 337 | + |
| 338 | + |
| 339 | +def draw_quiverkey_zorder_argument(fig, zorder=None): |
| 340 | + """Draw Quiver and QuiverKey using zorder argument""" |
| 341 | + x = np.arange(1, 6, 1) |
| 342 | + y = np.arange(1, 6, 1) |
| 343 | + X, Y = np.meshgrid(x, y) |
| 344 | + U, V = 2, 2 |
| 345 | + |
| 346 | + ax = fig.subplots() |
| 347 | + q = ax.quiver(X, Y, U, V, pivot='middle') |
| 348 | + ax.set_xlim(0.5, 5.5) |
| 349 | + ax.set_ylim(0.5, 5.5) |
| 350 | + if zorder is None: |
| 351 | + ax.quiverkey(q, 4, 4, 25, coordinates='data', |
| 352 | + label='U', color='blue') |
| 353 | + ax.quiverkey(q, 5.5, 2, 20, coordinates='data', |
| 354 | + label='V', color='blue', angle=90) |
| 355 | + else: |
| 356 | + ax.quiverkey(q, 4, 4, 25, coordinates='data', |
| 357 | + label='U', color='blue', zorder=zorder) |
| 358 | + ax.quiverkey(q, 5.5, 2, 20, coordinates='data', |
| 359 | + label='V', color='blue', angle=90, zorder=zorder) |
| 360 | + |
| 361 | + |
| 362 | +def draw_quiverkey_setzorder(fig, zorder=None): |
| 363 | + """Draw Quiver and QuiverKey using set_zorder""" |
| 364 | + x = np.arange(1, 6, 1) |
| 365 | + y = np.arange(1, 6, 1) |
| 366 | + X, Y = np.meshgrid(x, y) |
| 367 | + U, V = 2, 2 |
| 368 | + |
| 369 | + ax = fig.subplots() |
| 370 | + q = ax.quiver(X, Y, U, V, pivot='middle') |
| 371 | + ax.set_xlim(0.5, 5.5) |
| 372 | + ax.set_ylim(0.5, 5.5) |
| 373 | + qk1 = ax.quiverkey(q, 4, 4, 25, coordinates='data', |
| 374 | + label='U', color='blue') |
| 375 | + qk2 = ax.quiverkey(q, 5.5, 2, 20, coordinates='data', |
| 376 | + label='V', color='blue', angle=90) |
| 377 | + if zorder is not None: |
| 378 | + qk1.set_zorder(zorder) |
| 379 | + qk2.set_zorder(zorder) |
| 380 | + |
| 381 | + |
| 382 | +@pytest.mark.parametrize('zorder', [0, 2, 5, None]) |
| 383 | +@check_figures_equal(extensions=['png']) |
| 384 | +def test_quiverkey_zorder(fig_test, fig_ref, zorder): |
| 385 | + draw_quiverkey_zorder_argument(fig_test, zorder=zorder) |
| 386 | + draw_quiverkey_setzorder(fig_ref, zorder=zorder) |
0 commit comments