@@ -96,8 +96,6 @@ def get_tick_iterators(self, axes):
96
96
# c, angle, l is position, tick angle, and label
97
97
98
98
return iter_major, iter_minor
99
-
100
-
101
99
"""
102
100
103
101
class _Base :
@@ -138,7 +136,7 @@ def __init__(self, loc, nth_coord=None):
138
136
139
137
_verts = np .array ([[0. , 0. ],
140
138
[1. , 1. ]])
141
- fixed_coord = 1 - nth_coord
139
+ fixed_coord = 1 - nth_coord
142
140
_verts [:, fixed_coord ] = self .passthru_pt [fixed_coord ]
143
141
144
142
# axis line in transAxes
@@ -166,21 +164,16 @@ def get_axislabel_pos_angle(self, axes):
166
164
167
165
get_label_transform() returns a transform of (transAxes+offset)
168
166
"""
169
- loc = self ._loc
170
- pos , angle_tangent = dict (left = ((0. , 0.5 ), 90 ),
171
- right = ((1. , 0.5 ), 90 ),
172
- bottom = ((0.5 , 0. ), 0 ),
173
- top = ((0.5 , 1. ), 0 ))[loc ]
174
-
175
- return pos , angle_tangent
167
+ return dict (left = ((0. , 0.5 ), 90 ), # (position, angle_tangent)
168
+ right = ((1. , 0.5 ), 90 ),
169
+ bottom = ((0.5 , 0. ), 0 ),
170
+ top = ((0.5 , 1. ), 0 ))[self ._loc ]
176
171
177
172
# TICK
178
173
179
174
def get_tick_transform (self , axes ):
180
- trans_tick = [axes .get_xaxis_transform (),
181
- axes .get_yaxis_transform ()][self .nth_coord ]
182
-
183
- return trans_tick
175
+ return [axes .get_xaxis_transform (),
176
+ axes .get_yaxis_transform ()][self .nth_coord ]
184
177
185
178
class Floating (_Base ):
186
179
@@ -229,9 +222,7 @@ def get_tick_iterators(self, axes):
229
222
minorLocs = minor .locator ()
230
223
minorLabels = minor .formatter .format_ticks (minorLocs )
231
224
232
- trans_tick = self .get_tick_transform (axes )
233
-
234
- tr2ax = trans_tick + axes .transAxes .inverted ()
225
+ tick_to_axes = self .get_tick_transform (axes ) - axes .transAxes
235
226
236
227
def _f (locs , labels ):
237
228
for x , l in zip (locs , labels ):
@@ -240,7 +231,7 @@ def _f(locs, labels):
240
231
c [self .nth_coord ] = x
241
232
242
233
# check if the tick point is inside axes
243
- c2 = tr2ax .transform (c )
234
+ c2 = tick_to_axes .transform (c )
244
235
if (0 - self .delta1
245
236
<= c2 [self .nth_coord ]
246
237
<= 1 + self .delta2 ):
@@ -260,8 +251,8 @@ def get_line(self, axes):
260
251
[1. , 1. ]])
261
252
262
253
fixed_coord = 1 - self .nth_coord
263
- p = ( axes .transData + axes .transAxes . inverted ()). transform (
264
- [self ._value , self ._value ])
254
+ data_to_axes = axes .transData - axes .transAxes
255
+ p = data_to_axes . transform ( [self ._value , self ._value ])
265
256
_verts [:, fixed_coord ] = p [fixed_coord ]
266
257
267
258
return Path (_verts )
@@ -278,42 +269,27 @@ def get_axislabel_pos_angle(self, axes):
278
269
279
270
get_label_transform() returns a transform of (transAxes+offset)
280
271
"""
281
- if self .nth_coord == 0 :
282
- angle = 0
283
- else :
284
- angle = 90
285
-
272
+ angle = [0 , 90 ][self .nth_coord ]
286
273
_verts = [0.5 , 0.5 ]
287
-
288
- fixed_coord = 1 - self .nth_coord
289
- p = (axes .transData + axes .transAxes .inverted ()).transform (
290
- [self ._value , self ._value ])
274
+ fixed_coord = 1 - self .nth_coord
275
+ data_to_axes = axes .transData - axes .transAxes
276
+ p = data_to_axes .transform ([self ._value , self ._value ])
291
277
_verts [fixed_coord ] = p [fixed_coord ]
292
- if not (0. <= _verts [fixed_coord ] <= 1. ):
293
- return None , None
294
- else :
278
+ if 0 <= _verts [fixed_coord ] <= 1 :
295
279
return _verts , angle
280
+ else :
281
+ return None , None
296
282
297
283
def get_tick_transform (self , axes ):
298
284
return axes .transData
299
285
300
286
def get_tick_iterators (self , axes ):
301
287
"""tick_loc, tick_angle, tick_label"""
302
-
303
- loc = self ._axis_direction
304
-
305
- if loc in ["bottom" , "top" ]:
306
- angle_normal , angle_tangent = 90 , 0
307
- else :
308
- angle_normal , angle_tangent = 0 , 90
309
-
310
288
if self .nth_coord == 0 :
311
289
angle_normal , angle_tangent = 90 , 0
312
290
else :
313
291
angle_normal , angle_tangent = 0 , 90
314
292
315
- # angle = 90 - 90 * self.nth_coord
316
-
317
293
major = self .axis .major
318
294
majorLocs = major .locator ()
319
295
majorLabels = major .formatter .format_ticks (majorLocs )
@@ -322,14 +298,13 @@ def get_tick_iterators(self, axes):
322
298
minorLocs = minor .locator ()
323
299
minorLabels = minor .formatter .format_ticks (minorLocs )
324
300
325
- tr2ax = axes .transData + axes .transAxes . inverted ()
301
+ data_to_axes = axes .transData - axes .transAxes
326
302
327
303
def _f (locs , labels ):
328
304
for x , l in zip (locs , labels ):
329
-
330
305
c = [self ._value , self ._value ]
331
306
c [self .nth_coord ] = x
332
- c1 , c2 = tr2ax .transform (c )
307
+ c1 , c2 = data_to_axes .transform (c )
333
308
if (0 <= c1 <= 1 and 0 <= c2 <= 1
334
309
and 0 - self .delta1
335
310
<= [c1 , c2 ][self .nth_coord ]
0 commit comments