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

Function test_shared_with_aspect_3

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

Source from the content-addressed store, hash-verified

6431
6432
6433def test_shared_with_aspect_3():
6434 # Different aspect ratios:
6435 for adjustable in ['box', 'datalim']:
6436 fig, axs = plt.subplots(nrows=2, sharey=True)
6437 axs[0].set_aspect(2, adjustable=adjustable)
6438 axs[1].set_aspect(0.5, adjustable=adjustable)
6439 axs[0].plot([1, 2], [3, 4])
6440 axs[1].plot([3, 4], [1, 2])
6441 plt.draw() # Trigger apply_aspect().
6442 assert axs[0].get_xlim() != axs[1].get_xlim()
6443 assert axs[0].get_ylim() == axs[1].get_ylim()
6444 fig_aspect = fig.bbox_inches.height / fig.bbox_inches.width
6445 for ax in axs:
6446 p = ax.get_position()
6447 box_aspect = p.height / p.width
6448 lim_aspect = ax.viewLim.height / ax.viewLim.width
6449 expected = fig_aspect * box_aspect / lim_aspect
6450 assert round(expected, 4) == round(ax.get_aspect(), 4)
6451
6452
6453def test_shared_aspect_error():

Callers

nothing calls this directly

Calls 8

subplotsMethod · 0.45
set_aspectMethod · 0.45
plotMethod · 0.45
drawMethod · 0.45
get_xlimMethod · 0.45
get_ylimMethod · 0.45
get_positionMethod · 0.45
get_aspectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…