|
8 | 8 | import matplotlib |
9 | 9 | import matplotlib.pyplot as plt |
10 | 10 | from matplotlib.testing.decorators import image_comparison |
| 11 | +from matplotlib.gridspec import GridSpec |
11 | 12 |
|
12 | 13 |
|
13 | 14 | needs_usetex = pytest.mark.skipif( |
@@ -499,3 +500,19 @@ def test_text_repr(): |
499 | 500 | plt.plot(['A', 'B'], [1, 2]) |
500 | 501 | txt = plt.text(['A'], 0.5, 'Boo') |
501 | 502 | print(txt) |
| 503 | + |
| 504 | + |
| 505 | +@image_comparison(baseline_images=['text_annotation'], |
| 506 | + extensions=['png']) |
| 507 | +def test_annotation(): |
| 508 | + fig = plt.figure() |
| 509 | + spec = matplotlib.gridspec.GridSpec(ncols=3, nrows=3) |
| 510 | + anno_opts = dict(xy=(0.5, 0.5), xycoords='axes fraction', |
| 511 | + va='center', ha='center') |
| 512 | + |
| 513 | + fig.add_subplot(spec[0, 0]).annotate('GridSpec[0, 0]', **anno_opts) |
| 514 | + fig.add_subplot(spec[0, 1:]).annotate('GridSpec[0, 1:]', **anno_opts) |
| 515 | + fig.add_subplot(spec[1:, 0]).annotate('GridSpec[1:, 0]', **anno_opts) |
| 516 | + fig.add_subplot(spec[1:, 1:]).annotate('GridSpec[1:, 1:]', **anno_opts) |
| 517 | + |
| 518 | + fig.tight_layout() |
0 commit comments