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

Skip to content

Commit d6208e9

Browse files
committed
TST: add tighbbox tests
1 parent d6c5c7d commit d6208e9

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
@@ -382,3 +382,14 @@ def test_figure_repr():
382382
def test_fspath(fmt):
383383
from pathlib import Path
384384
plt.savefig(Path(os.devnull), format=fmt)
385+
386+
387+
def test_tightbbox():
388+
fig, ax = plt.subplots()
389+
ax.set_xlim(0, 1)
390+
t = ax.text(1., 0.5, 'This dangles over end')
391+
renderer = fig.canvas.get_renderer()
392+
assert np.abs(t.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
393+
assert np.abs(ax.get_tightbbox(renderer).x1 - 9.035 * fig.dpi) < 2
394+
assert np.abs(fig.get_tightbbox(renderer).x1 - 9.035) < 0.05
395+
assert np.abs(fig.get_tightbbox(renderer).x0 - 0.679) < 0.05

0 commit comments

Comments
 (0)
0