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

Skip to content

Commit 0f7b217

Browse files
committed
TST: add tests for not wrapping annotation coords
This is codifying the API change that went it in matplotlib#2351
1 parent 7b71257 commit 0f7b217

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
25.6 KB
Loading
26.8 KB
Loading

lib/matplotlib/tests/test_text.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,67 @@ def test_get_rotation_mod360():
305305
for i, j in zip([360., 377., 720+177.2], [0., 17., 177.2]):
306306
assert_almost_equal(text.get_rotation(i), j)
307307

308+
308309
@image_comparison(baseline_images=['text_bboxclip'])
309310
def test_bbox_clipping():
310311
plt.text(0.9, 0.2, 'Is bbox clipped?', backgroundcolor='r', clip_on=True)
311312
t = plt.text(0.9, 0.5, 'Is fancy bbox clipped?', clip_on=True)
312313
t.set_bbox({"boxstyle": "round, pad=0.1"})
314+
315+
316+
@image_comparison(baseline_images=['annotation_negative_ax_coords'],
317+
extensions=['png'])
318+
def test_annotation_negative_ax_coords():
319+
fig, ax = plt.subplots()
320+
321+
ax.annotate('+ pts',
322+
xytext=[30, 20], textcoords='axes points',
323+
xy=[30, 20], xycoords='axes points', fontsize=32)
324+
ax.annotate('- pts',
325+
xytext=[30, -20], textcoords='axes points',
326+
xy=[30, -20], xycoords='axes points', fontsize=32,
327+
va='top')
328+
ax.annotate('+ frac',
329+
xytext=[0.75, 0.05], textcoords='axes fraction',
330+
xy=[0.75, 0.05], xycoords='axes fraction', fontsize=32)
331+
ax.annotate('- frac',
332+
xytext=[0.75, -0.05], textcoords='axes fraction',
333+
xy=[0.75, -0.05], xycoords='axes fraction', fontsize=32,
334+
va='top')
335+
336+
ax.annotate('+ pixels',
337+
xytext=[160, 25], textcoords='axes pixels',
338+
xy=[160, 25], xycoords='axes pixels', fontsize=32)
339+
ax.annotate('- pixels',
340+
xytext=[160, -25], textcoords='axes pixels',
341+
xy=[160, -25], xycoords='axes pixels', fontsize=32,
342+
va='top')
343+
344+
345+
@image_comparison(baseline_images=['annotation_negative_fig_coords'],
346+
extensions=['png'])
347+
def test_annotation_negative_fig_coords():
348+
fig, ax = plt.subplots()
349+
350+
ax.annotate('+ pts',
351+
xytext=[10, 120], textcoords='figure points',
352+
xy=[10, 120], xycoords='figure points', fontsize=32)
353+
ax.annotate('- pts',
354+
xytext=[-10, 180], textcoords='figure points',
355+
xy=[-10, 180], xycoords='figure points', fontsize=32,
356+
va='top')
357+
ax.annotate('+ frac',
358+
xytext=[0.05, 0.55], textcoords='figure fraction',
359+
xy=[0.05, 0.55], xycoords='figure fraction', fontsize=32)
360+
ax.annotate('- frac',
361+
xytext=[-0.05, 0.5], textcoords='figure fraction',
362+
xy=[-0.05, 0.5], xycoords='figure fraction', fontsize=32,
363+
va='top')
364+
365+
ax.annotate('+ pixels',
366+
xytext=[50, 50], textcoords='figure pixels',
367+
xy=[50, 50], xycoords='figure pixels', fontsize=32)
368+
ax.annotate('- pixels',
369+
xytext=[-50, 100], textcoords='figure pixels',
370+
xy=[-50, 100], xycoords='figure pixels', fontsize=32,
371+
va='top')

0 commit comments

Comments
 (0)