5
5
from numpy .testing import assert_allclose
6
6
import pytest
7
7
8
- from matplotlib .testing .decorators import image_comparison
8
+ from matplotlib .testing .decorators import check_figures_equal , image_comparison
9
9
import matplotlib .pyplot as plt
10
10
import matplotlib .patches as mpatches
11
11
import matplotlib .lines as mlines
@@ -28,6 +28,7 @@ def test_offsetbox_clipping():
28
28
fig , ax = plt .subplots ()
29
29
size = 100
30
30
da = DrawingArea (size , size , clip = True )
31
+ assert da .clip_children
31
32
bg = mpatches .Rectangle ((0 , 0 ), size , size ,
32
33
facecolor = '#CCCCCC' ,
33
34
edgecolor = 'None' ,
@@ -335,3 +336,39 @@ def test_arrowprops_copied():
335
336
arrowprops = arrowprops )
336
337
assert ab .arrowprops is not ab
337
338
assert arrowprops ["relpos" ] == (.3 , .7 )
339
+
340
+
341
+ def test_annotationbbox_properties ():
342
+ ab = AnnotationBbox (DrawingArea (20 , 20 , 0 , 0 , clip = True ), (0.5 , 0.5 ),
343
+ xycoords = 'data' )
344
+ assert ab .xyann == (0.5 , 0.5 ) # xy if xybox not given
345
+ assert ab .anncoords == 'data' # xycoords if boxcoords not given
346
+
347
+ ab = AnnotationBbox (DrawingArea (20 , 20 , 0 , 0 , clip = True ), (0.5 , 0.5 ),
348
+ xybox = (- 0.2 , 0.4 ), xycoords = 'data' ,
349
+ boxcoords = 'axes fraction' )
350
+ assert ab .xyann == (- 0.2 , 0.4 ) # xybox if given
351
+ assert ab .anncoords == 'axes fraction' # boxcoords if given
352
+
353
+
354
+ def test_textarea_properties ():
355
+ ta = TextArea ('Foo' )
356
+ assert ta .get_text () == 'Foo'
357
+ assert not ta .get_multilinebaseline ()
358
+
359
+ ta .set_text ('Bar' )
360
+ ta .set_multilinebaseline (True )
361
+ assert ta .get_text () == 'Bar'
362
+ assert ta .get_multilinebaseline ()
363
+
364
+
365
+ @check_figures_equal ()
366
+ def test_textarea_set_text (fig_test , fig_ref ):
367
+ ax_ref = fig_ref .add_subplot ()
368
+ text0 = AnchoredText ("Foo" , "upper left" )
369
+ ax_ref .add_artist (text0 )
370
+
371
+ ax_test = fig_test .add_subplot ()
372
+ text1 = AnchoredText ("Bar" , "upper left" )
373
+ ax_test .add_artist (text1 )
374
+ text1 .txt .set_text ("Foo" )
0 commit comments