18
18
def test_patch_transform_of_none ():
19
19
# tests the behaviour of patches added to an Axes with various transform
20
20
# specifications
21
-
21
+
22
22
ax = plt .axes ()
23
23
ax .set_xlim ([1 , 3 ])
24
24
ax .set_ylim ([1 , 3 ])
25
-
25
+
26
26
# Draw an ellipse over data coord (2,2) by specifying device coords.
27
27
xy_data = (2 , 2 )
28
28
xy_pix = ax .transData .transform_point (xy_data )
29
-
29
+
30
30
# Not providing a transform of None puts the ellipse in data coordinates .
31
31
e = mpatches .Ellipse (xy_data , width = 1 , height = 1 , fc = 'yellow' , alpha = 0.5 )
32
32
ax .add_patch (e )
33
33
assert e ._transform == ax .transData
34
-
34
+
35
35
# Providing a transform of None puts the ellipse in device coordinates.
36
- e = mpatches .Ellipse (xy_pix , width = 120 , height = 120 , fc = 'coral' ,
36
+ e = mpatches .Ellipse (xy_pix , width = 120 , height = 120 , fc = 'coral' ,
37
37
transform = None , alpha = 0.5 )
38
38
assert e .is_transform_set () is True
39
39
ax .add_patch (e )
40
40
assert isinstance (e ._transform , mtrans .IdentityTransform )
41
-
41
+
42
42
# Providing an IdentityTransform puts the ellipse in device coordinates.
43
- e = mpatches .Ellipse (xy_pix , width = 100 , height = 100 ,
43
+ e = mpatches .Ellipse (xy_pix , width = 100 , height = 100 ,
44
44
transform = mtrans .IdentityTransform (), alpha = 0.5 )
45
45
ax .add_patch (e )
46
46
assert isinstance (e ._transform , mtrans .IdentityTransform )
@@ -55,39 +55,39 @@ def test_patch_transform_of_none():
55
55
assert e .get_transform () != intermediate_transform
56
56
assert e .is_transform_set () is True
57
57
assert e ._transform == ax .transData
58
-
58
+
59
59
60
60
@cleanup
61
61
def test_collection_transform_of_none ():
62
- # tests the behaviour of collections added to an Axes with various
62
+ # tests the behaviour of collections added to an Axes with various
63
63
# transform specifications
64
64
65
65
ax = plt .axes ()
66
66
ax .set_xlim ([1 , 3 ])
67
67
ax .set_ylim ([1 , 3 ])
68
-
68
+
69
69
#draw an ellipse over data coord (2,2) by specifying device coords
70
70
xy_data = (2 , 2 )
71
71
xy_pix = ax .transData .transform_point (xy_data )
72
-
73
- # not providing a transform of None puts the ellipse in data coordinates
72
+
73
+ # not providing a transform of None puts the ellipse in data coordinates
74
74
e = mpatches .Ellipse (xy_data , width = 1 , height = 1 )
75
75
c = mcollections .PatchCollection ([e ], facecolor = 'yellow' , alpha = 0.5 )
76
76
ax .add_collection (c )
77
- # the collection should be in data coordinates
77
+ # the collection should be in data coordinates
78
78
assert c .get_offset_transform () + c .get_transform () == ax .transData
79
-
79
+
80
80
# providing a transform of None puts the ellipse in device coordinates
81
81
e = mpatches .Ellipse (xy_pix , width = 120 , height = 120 )
82
- c = mcollections .PatchCollection ([e ], facecolor = 'coral' ,
82
+ c = mcollections .PatchCollection ([e ], facecolor = 'coral' ,
83
83
alpha = 0.5 )
84
- c .set_transform (None )
84
+ c .set_transform (None )
85
85
ax .add_collection (c )
86
86
assert isinstance (c .get_transform (), mtrans .IdentityTransform )
87
-
87
+
88
88
# providing an IdentityTransform puts the ellipse in device coordinates
89
89
e = mpatches .Ellipse (xy_pix , width = 100 , height = 100 )
90
- c = mcollections .PatchCollection ([e ], transform = mtrans .IdentityTransform (),
90
+ c = mcollections .PatchCollection ([e ], transform = mtrans .IdentityTransform (),
91
91
alpha = 0.5 )
92
92
ax .add_collection (c )
93
93
assert isinstance (c ._transOffset , mtrans .IdentityTransform )
@@ -100,7 +100,7 @@ def test_point_in_path():
100
100
path = mpath .Path (verts2 , closed = True )
101
101
points = [(0.5 ,0.5 ), (1.5 ,0.5 )]
102
102
103
- assert np .all (path .contains_points (points ) == [True , False ])
103
+ assert np .all (path .contains_points (points ) == [True , False ])
104
104
105
105
106
106
@image_comparison (baseline_images = ["clip_path_clipping" ], remove_text = True )
@@ -111,6 +111,8 @@ def test_clipping():
111
111
exterior .vertices *= 4
112
112
exterior .vertices -= 2
113
113
interior = mpath .Path .unit_circle ()
114
+ interior = mpath .Path (copy .deepcopy (interior .vertices ),
115
+ copy .deepcopy (interior .codes [:]))
114
116
interior .vertices = interior .vertices [::- 1 ]
115
117
clip_path = mpath .Path (vertices = np .concatenate ([exterior .vertices ,
116
118
interior .vertices ]),
@@ -125,7 +127,7 @@ def test_clipping():
125
127
facecolor = 'red' , alpha = 0.7 , hatch = '*' )
126
128
col .set_clip_path (clip_path , ax1 .transData )
127
129
ax1 .add_collection (col )
128
-
130
+
129
131
ax2 = plt .subplot (122 , sharex = ax1 , sharey = ax1 )
130
132
patch = mpatches .PathPatch (star , lw = 5 , edgecolor = 'blue' , facecolor = 'red' ,
131
133
alpha = 0.7 , hatch = '*' )
0 commit comments