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

Function test_box_aspect

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

Source from the content-addressed store, hash-verified

8981
8982
8983def test_box_aspect():
8984 # Test if axes with box_aspect=1 has same dimensions
8985 # as axes with aspect equal and adjustable="box"
8986
8987 fig1, ax1 = plt.subplots()
8988 axtwin = ax1.twinx()
8989 axtwin.plot([12, 344])
8990
8991 ax1.set_box_aspect(1)
8992 assert ax1.get_box_aspect() == 1.0
8993
8994 fig2, ax2 = plt.subplots()
8995 ax2.margins(0)
8996 ax2.plot([0, 2], [6, 8])
8997 ax2.set_aspect("equal", adjustable="box")
8998
8999 fig1.canvas.draw()
9000 fig2.canvas.draw()
9001
9002 bb1 = ax1.get_position()
9003 bbt = axtwin.get_position()
9004 bb2 = ax2.get_position()
9005
9006 assert_array_equal(bb1.extents, bb2.extents)
9007 assert_array_equal(bbt.extents, bb2.extents)
9008
9009
9010def test_box_aspect_custom_position():

Callers

nothing calls this directly

Calls 9

get_box_aspectMethod · 0.80
subplotsMethod · 0.45
twinxMethod · 0.45
plotMethod · 0.45
set_box_aspectMethod · 0.45
marginsMethod · 0.45
set_aspectMethod · 0.45
drawMethod · 0.45
get_positionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…