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

Function test_indicate_inset_inverted

lib/matplotlib/tests/test_axes.py:8407–8428  ·  view source on GitHub ↗

Test that the inset lines are correctly located with inverted data axes.

(x_inverted, y_inverted)

Source from the content-addressed store, hash-verified

8405@pytest.mark.parametrize('x_inverted', [False, True])
8406@pytest.mark.parametrize('y_inverted', [False, True])
8407def test_indicate_inset_inverted(x_inverted, y_inverted):
8408 """
8409 Test that the inset lines are correctly located with inverted data axes.
8410 """
8411 fig, (ax1, ax2) = plt.subplots(1, 2)
8412
8413 x = np.arange(10)
8414 ax1.plot(x, x, 'o')
8415 if x_inverted:
8416 ax1.invert_xaxis()
8417 if y_inverted:
8418 ax1.invert_yaxis()
8419
8420 inset = ax1.indicate_inset([2, 2, 5, 4], ax2)
8421 lower_left, upper_left, lower_right, upper_right = inset.connectors
8422
8423 sign_x = -1 if x_inverted else 1
8424 sign_y = -1 if y_inverted else 1
8425 assert sign_x * (lower_right.xy2[0] - lower_left.xy2[0]) > 0
8426 assert sign_x * (upper_right.xy2[0] - upper_left.xy2[0]) > 0
8427 assert sign_y * (upper_left.xy2[1] - lower_left.xy2[1]) > 0
8428 assert sign_y * (upper_right.xy2[1] - lower_right.xy2[1]) > 0
8429
8430
8431def test_set_position():

Callers

nothing calls this directly

Calls 5

invert_yaxisMethod · 0.80
indicate_insetMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
invert_xaxisMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…