8000 TST: add tighbbox tests · matplotlib/matplotlib@880f531 · GitHub
[go: up one dir, main page]

Skip to content

Commit 880f531

Browse files
committed
TST: add tighbbox tests
1 parent 06e03b6 commit 880f531

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
@@ -385,3 +385,14 @@ def test_fspath(fmt, tmpdir):
385385
# All the supported formats include the format name (case-insensitive)
386386
# in the first 100 bytes.
387387
assert fmt.encode("ascii") in file.read(100).lower()
388+
389+
390+
def test_tightbbox():
391+
fig, ax = plt.subplots()
392+
ax.set_xlim(0, 1)
393+
t = ax.text(1., 0.5, 'This dangles over end')
394+
renderer = fig.canvas.get_renderer()
395+
assert np.abs(t.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
396+
assert np.abs(ax.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
397+
assert np.abs(fig.get_tightbbox(renderer).x1 - 9.035) < 0.05
398+
assert np.abs(fig.get_tightbbox(renderer).x0 - 0.679) < 0.05

0 commit comments

Comments
 (0)
0