@@ -96,8 +96,6 @@ def get_tick_iterators(self, axes):
9696 # c, angle, l is position, tick angle, and label
9797
9898 return iter_major, iter_minor
99-
100-
10199 """
102100
103101 class _Base :
@@ -138,7 +136,7 @@ def __init__(self, loc, nth_coord=None):
138136
139137 _verts = np .array ([[0. , 0. ],
140138 [1. , 1. ]])
141- fixed_coord = 1 - nth_coord
139+ fixed_coord = 1 - nth_coord
142140 _verts [:, fixed_coord ] = self .passthru_pt [fixed_coord ]
143141
144142 # axis line in transAxes
@@ -166,21 +164,16 @@ def get_axislabel_pos_angle(self, axes):
166164
167165 get_label_transform() returns a transform of (transAxes+offset)
168166 """
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 ]
176171
177172 # TICK
178173
179174 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 ]
184177
185178 class Floating (_Base ):
186179
@@ -229,9 +222,7 @@ def get_tick_iterators(self, axes):
229222 minorLocs = minor .locator ()
230223 minorLabels = minor .formatter .format_ticks (minorLocs )
231224
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
235226
236227 def _f (locs , labels ):
237228 for x , l in zip (locs , labels ):
@@ -240,7 +231,7 @@ def _f(locs, labels):
240231 c [self .nth_coord ] = x
241232
242233 # check if the tick point is inside axes
243- c2 = tr2ax .transform (c )
234+ c2 = tick_to_axes .transform (c )
244235 if (0 - self .delta1
245236 <= c2 [self .nth_coord ]
246237 <= 1 + self .delta2 ):
@@ -260,8 +251,8 @@ def get_line(self, axes):
260251 [1. , 1. ]])
261252
262253 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 ])
265256 _verts [:, fixed_coord ] = p [fixed_coord ]
266257
267258 return Path (_verts )
@@ -278,42 +269,27 @@ def get_axislabel_pos_angle(self, axes):
278269
279270 get_label_transform() returns a transform of (transAxes+offset)
280271 """
281- if self .nth_coord == 0 :
282- angle = 0
283- else :
284- angle = 90
285-
272+ angle = [0 , 90 ][self .nth_coord ]
286273 _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 ])
291277 _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 :
295279 return _verts , angle
280+ else :
281+ return None , None
296282
297283 def get_tick_transform (self , axes ):
298284 return axes .transData
299285
300286 def get_tick_iterators (self , axes ):
301287 """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-
310288 if self .nth_coord == 0 :
311289 angle_normal , angle_tangent = 90 , 0
312290 else :
313291 angle_normal , angle_tangent = 0 , 90
314292
315- # angle = 90 - 90 * self.nth_coord
316-
317293 major = self .axis .major
318294 majorLocs = major .locator ()
319295 majorLabels = major .formatter .format_ticks (majorLocs )
@@ -322,14 +298,13 @@ def get_tick_iterators(self, axes):
322298 minorLocs = minor .locator ()
323299 minorLabels = minor .formatter .format_ticks (minorLocs )
324300
325- tr2ax = axes .transData + axes .transAxes . inverted ()
301+ data_to_axes = axes .transData - axes .transAxes
326302
327303 def _f (locs , labels ):
328304 for x , l in zip (locs , labels ):
329-
330305 c = [self ._value , self ._value ]
331306 c [self .nth_coord ] = x
332- c1 , c2 = tr2ax .transform (c )
307+ c1 , c2 = data_to_axes .transform (c )
333308 if (0 <= c1 <= 1 and 0 <= c2 <= 1
334309 and 0 - self .delta1
335310 <= [c1 , c2 ][self .nth_coord ]
0 commit comments