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

Function test_legend_text

lib/matplotlib/tests/test_legend.py:1617–1631  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1615
1616
1617def test_legend_text():
1618 # Test that legend is place in the correct
1619 # position for 'best' when there is text in figure
1620 fig, axs = plt.subplots(ncols=2, figsize=(10, 5))
1621 leg_bboxes = []
1622 for ax, loc in zip(axs.flat, ('best', 'lower left')):
1623 x = [1, 2]
1624 y = [2, 1]
1625 ax.plot(x, y, label='plot name')
1626 ax.text(1.5, 2, 'some text blahblah', verticalalignment='top')
1627 leg = ax.legend(loc=loc)
1628 fig.canvas.draw()
1629 leg_bboxes.append(
1630 leg.get_window_extent().transformed(ax.transAxes.inverted()))
1631 assert_allclose(leg_bboxes[1].bounds, leg_bboxes[0].bounds)
1632
1633
1634def test_legend_annotate():

Callers

nothing calls this directly

Calls 8

subplotsMethod · 0.45
plotMethod · 0.45
textMethod · 0.45
legendMethod · 0.45
drawMethod · 0.45
transformedMethod · 0.45
get_window_extentMethod · 0.45
invertedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…