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

Function test_legend_loc_polycollection

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

Source from the content-addressed store, hash-verified

1596
1597
1598def test_legend_loc_polycollection():
1599 # Test that the legend is placed in the correct
1600 # position for 'best' for polycollection
1601 x = [3, 4, 5]
1602 y1 = [1, 1, 1]
1603 y2 = [5, 5, 5]
1604 leg_bboxes = []
1605 fig, axs = plt.subplots(ncols=2, figsize=(10, 5))
1606 for ax, loc in zip(axs.flat, ('best', 'lower left')):
1607 ax.fill_between(x, y1, y2, color='gray', alpha=0.5, label='Shaded Area')
1608 ax.set_xlim(0, 6)
1609 ax.set_ylim(-1, 5)
1610 leg = ax.legend(loc=loc)
1611 fig.canvas.draw()
1612 leg_bboxes.append(
1613 leg.get_window_extent().transformed(ax.transAxes.inverted()))
1614 assert_allclose(leg_bboxes[1].bounds, leg_bboxes[0].bounds)
1615
1616
1617def test_legend_text():

Callers

nothing calls this directly

Calls 9

subplotsMethod · 0.45
fill_betweenMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 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…