()
| 8544 | @image_comparison(['secondary_xy.png'], style='mpl20', |
| 8545 | tol=0 if platform.machine() == 'x86_64' else 0.024) |
| 8546 | def test_secondary_xy(): |
| 8547 | fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True) |
| 8548 | |
| 8549 | def invert(x): |
| 8550 | with np.errstate(divide='ignore'): |
| 8551 | return 1 / x |
| 8552 | |
| 8553 | for nn, ax in enumerate(axs): |
| 8554 | ax.plot(np.arange(2, 11), np.arange(2, 11)) |
| 8555 | if nn == 0: |
| 8556 | secax = ax.secondary_xaxis |
| 8557 | else: |
| 8558 | secax = ax.secondary_yaxis |
| 8559 | |
| 8560 | secax(0.2, functions=(invert, invert)) |
| 8561 | secax(0.4, functions=(lambda x: 2 * x, lambda x: x / 2)) |
| 8562 | secax(0.6, functions=(lambda x: x**2, lambda x: x**(1/2))) |
| 8563 | secax(0.8) |
| 8564 | secax("top" if nn == 0 else "right", functions=_Translation(2)) |
| 8565 | secax(6.25, transform=ax.transData) |
| 8566 | |
| 8567 | |
| 8568 | def test_secondary_fail(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…