5
5
6
6
import matplotlib .pyplot as plt
7
7
from matplotlib .testing .decorators import image_comparison
8
- import matplotlib
8
+ import matplotlib . patches as mpatches # adopting scipy import conventions
9
9
10
10
11
11
def draw_arrow (ax , t , r ):
@@ -18,7 +18,7 @@ def draw_arrow(ax, t, r):
18
18
def test_fancyarrow ():
19
19
# Added 0 to test division by zero error described in issue 3930
20
20
r = [0.4 , 0.3 , 0.2 , 0.1 , 0 ]
21
- t = ["fancy" , "simple" , matplotlib . patches .ArrowStyle .Fancy ()]
21
+ t = ["fancy" , "simple" , mpatches .ArrowStyle .Fancy ()]
22
22
23
23
fig , axes = plt .subplots (len (t ), len (r ), squeeze = False ,
24
24
subplot_kw = dict (aspect = True ),
@@ -34,7 +34,7 @@ def test_fancyarrow():
34
34
@image_comparison (baseline_images = ['boxarrow_test_image' ], extensions = ['png' ])
35
35
def test_boxarrow ():
36
36
37
- styles = matplotlib . patches .BoxStyle .get_styles ()
37
+ styles = mpatches .BoxStyle .get_styles ()
38
38
39
39
n = len (styles )
40
40
spacing = 1.2
@@ -52,52 +52,49 @@ def test_boxarrow():
52
52
bbox = dict (boxstyle = stylename , fc = "w" , ec = "k" ))
53
53
54
54
55
- def prepare_fancyarrow_for_head_size_test ():
55
+ def prepare_fancyarrow_dpi_cor_test ():
56
56
"""
57
57
Convenience function that prepares and return a FancyArrowPatch. It aims
58
58
at being used to test that the size of the arrow head does not depend on
59
- the DPI value of the exported picture.
59
+ the DPI value of the exported picture.
60
60
61
61
NB: this function *is not* a test in itself!
62
62
"""
63
- fig = plt .figure (figsize = (6 , 4 ), dpi = 50 )
64
- ax = fig .add_subplot (111 )
63
+ fig2 = plt .figure ("fancyarrow_dpi_cor_test" , figsize = (4 , 3 ), dpi = 50 )
64
+ ax = fig2 .add_subplot (111 )
65
65
ax .set_xlim ([0 , 1 ])
66
66
ax .set_ylim ([0 , 1 ])
67
67
ax .add_patch (mpatches .FancyArrowPatch (posA = (0.3 , 0.4 ), posB = (0.8 , 0.6 ),
68
- lw = 3 , arrowstyle = u'->' ,
69
- mutation_scale = 150 ))
70
- return fig
68
+ lw = 3 , arrowstyle = u'->' ,
69
+ mutation_scale = 100 ))
70
+ return fig2
71
71
72
72
73
- @image_comparison (baseline_images = ['fancyarrow_head_size_100dpi ' ],
74
- remove_text = True , extensions = ['svg' , 'pdf' , ' png' ],
75
- savefig_kwarg = dict (dpi = 100 ))
76
- def test_fancy_arrow_patch_head_size_100dpi ():
73
+ @image_comparison (baseline_images = ['fancyarrow_dpi_cor_100dpi ' ],
74
+ remove_text = True , extensions = ['png' ],
75
+ savefig_kwarg = dict (dpi = 100 ))
76
+ def test_fancyarrow_dpi_cor_100dpi ():
77
77
"""
78
- Check the export of a FancyArrowPatch @ 100 DPI. The FancyArrowPatch
79
- is instanciated through a dedicated function because another similar test
80
- checks the same export but with a different DPI value.
78
+ Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is
79
+ instanciated through a dedicated function because another similar test
80
+ checks a similar export but with a different DPI value.
81
81
82
- Remark: may be more explicit to create a dedicated test for SVG and PDF,
83
- as a DPI value is not very relevant here...
82
+ Remark: test only a rasterized format.
84
83
"""
85
-
86
- prepare_fancyarrow_for_head_size_test ()
87
84
85
+ prepare_fancyarrow_dpi_cor_test ()
88
86
89
- @ image_comparison ( baseline_images = [ 'fancyarrow_head_size_300dpi' ],
90
- remove_text = True ,
91
- extensions = ['png' ], # pdf and svg already tested @ 100 DPI
92
- savefig_kwarg = dict (dpi = 300 ))
93
- def test_fancy_arrow_patch_head_size_300dpi ():
87
+
88
+ @ image_comparison ( baseline_images = [ 'fancyarrow_dpi_cor_200dpi' ],
89
+ remove_text = True , extensions = ['png' ],
90
+ savefig_kwarg = dict (dpi = 200 ))
91
+ def test_fancyarrow_dpi_cor_200dpi ():
94
92
"""
95
- Check the export of a FancyArrowPatch @ 300 DPI. The FancyArrowPatch
96
- is instanciated through a dedicated function because another similar test
97
- checks the same export but with a different DPI value.
93
+ As test_fancyarrow_dpi_cor_100dpi, but exports @ 200 DPI. The relative size
94
+ of the arrow head should be the same.
98
95
"""
99
-
100
- prepare_fancyarrow_for_head_size_test ()
96
+
97
+ prepare_fancyarrow_dpi_cor_test ()
101
98
102
99
103
100
if __name__ == '__main__' :
0 commit comments