Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79fc9e5

Browse files
committed
Small simplifications to FixedAxisArtistHelper.
- change_tick_coords has never been used by any other function or in any example in the library's history, and is a custom API not even present on other AxisArtistHelpers, so deprecate it. - _limits_inverted is only used in get_tick_iterators, so one can just test limits inversion there instead of carrying one bit of state around.
1 parent d11b206 commit 79fc9e5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``FixedAxisArtistHelper.change_tick_coord``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated with no replacement.

lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,11 @@ def __init__(self, grid_helper, side, nth_coord_ticks=None):
3232
self.nth_coord_ticks = nth_coord_ticks
3333

3434
self.side = side
35-
self._limits_inverted = False
3635

3736
def update_lim(self, axes):
3837
self.grid_helper.update_lim(axes)
3938

40-
if self.nth_coord == 0:
41-
xy1, xy2 = axes.get_ylim()
42-
else:
43-
xy1, xy2 = axes.get_xlim()
44-
45-
if xy1 > xy2:
46-
self._limits_inverted = True
47-
else:
48-
self._limits_inverted = False
49-
39+
@_api.deprecated("3.5")
5040
def change_tick_coord(self, coord_number=None):
5141
if coord_number is None:
5242
self.nth_coord_ticks = 1 - self.nth_coord_ticks
@@ -60,18 +50,15 @@ def get_tick_transform(self, axes):
6050

6151
def get_tick_iterators(self, axes):
6252
"""tick_loc, tick_angle, tick_label"""
63-
64-
g = self.grid_helper
65-
66-
if self._limits_inverted:
53+
v1, v2 = axes.get_ylim() if self.nth_coord == 0 else axes.get_xlim()
54+
if v1 > v2: # Inverted limits.
6755
side = {"left": "right", "right": "left",
6856
"top": "bottom", "bottom": "top"}[self.side]
6957
else:
7058
side = self.side
71-
59+
g = self.grid_helper
7260
ti1 = g.get_tick_iterator(self.nth_coord_ticks, side)
7361
ti2 = g.get_tick_iterator(1-self.nth_coord_ticks, side, minor=True)
74-
7562
return chain(ti1, ti2), iter([])
7663

7764

0 commit comments

Comments
 (0)