MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_secondary_xy

Function test_secondary_xy

lib/matplotlib/tests/test_axes.py:8546–8565  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8544@image_comparison(['secondary_xy.png'], style='mpl20',
8545 tol=0 if platform.machine() == 'x86_64' else 0.024)
8546def 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
8568def test_secondary_fail():

Callers

nothing calls this directly

Calls 3

_TranslationClass · 0.85
subplotsMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…