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

Function test_legend_auto4

lib/matplotlib/tests/test_legend.py:90–109  ·  view source on GitHub ↗

Check that the legend location with automatic placement is the same, whatever the histogram type is. Related to issue #9580.

()

Source from the content-addressed store, hash-verified

88
89
90def test_legend_auto4():
91 """
92 Check that the legend location with automatic placement is the same,
93 whatever the histogram type is. Related to issue #9580.
94 """
95 # NB: barstacked is pointless with a single dataset.
96 fig, axs = plt.subplots(ncols=3, figsize=(6.4, 2.4))
97 leg_bboxes = []
98 for ax, ht in zip(axs.flat, ('bar', 'step', 'stepfilled')):
99 ax.set_title(ht)
100 # A high bar on the left but an even higher one on the right.
101 ax.hist([0] + 5*[9], bins=range(10), label="Legend", histtype=ht)
102 leg = ax.legend(loc="best")
103 fig.canvas.draw()
104 leg_bboxes.append(
105 leg.get_window_extent().transformed(ax.transAxes.inverted()))
106
107 # The histogram type "bar" is assumed to be the correct reference.
108 assert_allclose(leg_bboxes[1].bounds, leg_bboxes[0].bounds)
109 assert_allclose(leg_bboxes[2].bounds, leg_bboxes[0].bounds)
110
111
112def test_legend_auto5():

Callers

nothing calls this directly

Calls 8

histMethod · 0.80
subplotsMethod · 0.45
set_titleMethod · 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…