|
15 | 15 | from matplotlib.font_manager import FontProperties
|
16 | 16 | import matplotlib.patches as mpatches
|
17 | 17 | import matplotlib.pyplot as plt
|
| 18 | +from matplotlib.gridspec import GridSpec |
18 | 19 | import matplotlib.transforms as mtransforms
|
19 | 20 | from matplotlib.testing.decorators import check_figures_equal, image_comparison
|
20 | 21 | from matplotlib.testing._markers import needs_usetex
|
@@ -707,9 +708,13 @@ def test_large_subscript_title():
|
707 | 708 | (0.3, 0, 'right'),
|
708 | 709 | (0.3, 185, 'left')])
|
709 | 710 | def test_wrap(x, rotation, halign):
|
710 |
| - fig = plt.figure(figsize=(6, 6)) |
| 711 | + fig = plt.figure(figsize=(18, 18)) |
| 712 | + gs = GridSpec(nrows=3, ncols=3, figure=fig) |
| 713 | + subfig = fig.add_subfigure(gs[1, 1]) |
| 714 | + # we only use the central subfigure, which does not align with any |
| 715 | + # figure boundary, to ensure only subfigure boundaries are relevant |
711 | 716 | s = 'This is a very long text that should be wrapped multiple times.'
|
712 |
| - text = fig.text(x, 0.7, s, wrap=True, rotation=rotation, ha=halign) |
| 717 | + text = subfig.text(x, 0.7, s, wrap=True, rotation=rotation, ha=halign) |
713 | 718 | fig.canvas.draw()
|
714 | 719 | assert text._get_wrapped_text() == ('This is a very long\n'
|
715 | 720 | 'text that should be\n'
|
|
0 commit comments