25
25
# interval as appropriate and see what parts of the tick to draw, if any.
26
26
class SkewXTick (maxis .XTick ):
27
27
def draw (self , renderer ):
28
- if not self .get_visible (): return
28
+ if not self .get_visible ():
29
+ return
29
30
renderer .open_group (self .__name__ )
30
31
31
32
lower_interval = self .axes .xaxis .lower_interval
@@ -78,7 +79,7 @@ def __init__(self, axes, spine_type):
78
79
else :
79
80
loc = 1.0
80
81
mspines .Spine .__init__ (self , axes , spine_type ,
81
- mpath .Path ([(13 , loc ), (13 , loc )]))
82
+ mpath .Path ([(13 , loc ), (13 , loc )]))
82
83
83
84
def _adjust_location (self ):
84
85
trans = self .axes .transDataToAxes .inverted ()
@@ -89,7 +90,7 @@ def _adjust_location(self):
89
90
left = trans .transform_point ((0.0 , yloc ))[0 ]
90
91
right = trans .transform_point ((1.0 , yloc ))[0 ]
91
92
92
- pts = self ._path .vertices
93
+ pts = self ._path .vertices
93
94
pts [0 , 0 ] = left
94
95
pts [1 , 0 ] = right
95
96
self .axis .upper_interval = (left , right )
@@ -114,10 +115,10 @@ def _init_axis(self):
114
115
self .spines ['right' ].register_axis (self .yaxis )
115
116
116
117
def _gen_axes_spines (self ):
117
- spines = {'top' :SkewSpine (self , 'top' ),
118
- 'bottom' :mspines .Spine .linear_spine (self , 'bottom' ),
119
- 'left' :mspines .Spine .linear_spine (self , 'left' ),
120
- 'right' :mspines .Spine .linear_spine (self , 'right' )}
118
+ spines = {'top' : SkewSpine (self , 'top' ),
119
+ 'bottom' : mspines .Spine .linear_spine (self , 'bottom' ),
120
+ 'left' : mspines .Spine .linear_spine (self , 'left' ),
121
+ 'right' : mspines .Spine .linear_spine (self , 'right' )}
121
122
return spines
122
123
123
124
def _set_lim_and_transforms (self ):
@@ -135,23 +136,25 @@ def _set_lim_and_transforms(self):
135
136
# coordinates thus performing the transform around the proper origin
136
137
# We keep the pre-transAxes transform around for other users, like the
137
138
# spines for finding bounds
138
- self .transDataToAxes = self .transScale + (self .transLimits +
139
- transforms .Affine2D ().skew_deg (rot , 0 ))
139
+ self .transDataToAxes = (self .transScale +
140
+ (self .transLimits +
141
+ transforms .Affine2D ().skew_deg (rot , 0 )))
140
142
141
143
# Create the full transform from Data to Pixels
142
144
self .transData = self .transDataToAxes + self .transAxes
143
145
144
146
# Blended transforms like this need to have the skewing applied using
145
147
# both axes, in axes coords like before.
146
148
self ._xaxis_transform = (transforms .blended_transform_factory (
147
- self .transScale + self .transLimits ,
148
- transforms .IdentityTransform ()) +
149
- transforms .Affine2D ().skew_deg (rot , 0 )) + self .transAxes
149
+ self .transScale + self .transLimits ,
150
+ transforms .IdentityTransform ()) +
151
+ transforms .Affine2D ().skew_deg (rot , 0 )) + self .transAxes
150
152
151
153
# Now register the projection with matplotlib so the user can select
152
154
# it.
153
155
register_projection (SkewXAxes )
154
156
157
+
155
158
@image_comparison (baseline_images = ['skew_axes' ], remove_text = True )
156
159
def test_set_line_coll_dash_image ():
157
160
fig = plt .figure ()
@@ -163,6 +166,7 @@ def test_set_line_coll_dash_image():
163
166
# An example of a slanted line at constant X
164
167
l = ax .axvline (0 , color = 'b' )
165
168
169
+
166
170
@image_comparison (baseline_images = ['skew_rects' ], remove_text = True )
167
171
def test_skew_rectange ():
168
172
@@ -180,7 +184,8 @@ def test_skew_rectange():
180
184
t = transforms .Affine2D ().skew_deg (xdeg , ydeg )
181
185
182
186
ax .set_title ('Skew of {0} in X and {1} in Y' .format (xdeg , ydeg ))
183
- ax .add_patch (mpatch .Rectangle ([- 1 , - 1 ], 2 , 2 , transform = t + ax .transData ,
187
+ ax .add_patch (mpatch .Rectangle ([- 1 , - 1 ], 2 , 2 ,
188
+ transform = t + ax .transData ,
184
189
alpha = 0.5 , facecolor = 'coral' ))
185
190
186
191
plt .subplots_adjust (wspace = 0 , left = 0 , right = 1 , bottom = 0 )
0 commit comments