Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec263c1

Browse files
committed
TST: add tighbbox tests
1 parent 26461ef commit ec263c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/tests/test_figure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,14 @@ def test_fspath(fmt, tmpdir):
386386
# All the supported formats include the format name (case-insensitive)
387387
# in the first 100 bytes.
388388
assert fmt.encode("ascii") in file.read(100).lower()
389+
390+
391+
def test_tightbbox():
392+
fig, ax = plt.subplots()
393+
ax.set_xlim(0, 1)
394+
t = ax.text(1., 0.5, 'This dangles over end')
395+
renderer = fig.canvas.get_renderer()
396+
assert np.abs(t.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
397+
assert np.abs(ax.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
398+
assert np.abs(fig.get_tightbbox(renderer).x1 - 9.035) < 0.05
399+
assert np.abs(fig.get_tightbbox(renderer).x0 - 0.679) < 0.05

0 commit comments

Comments
 (0)