8000 Refactor AxisArtistHelpers · matplotlib/matplotlib@85e0f3c · GitHub
[go: up one dir, main page]

Skip to content

Commit 85e0f3c

Browse files
author
Oscar Gustafsson
committed
Refactor AxisArtistHelpers
1 parent bfff33b commit 85e0f3c

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/mpl_toolkits/axisartist/axislines.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ def get_tick_iterators(self, axes):
8484
return iter_major, iter_minor
8585
"""
8686

87+
def __init__(self, nth_coord):
88+
self.nth_coord = nth_coord
89+
8790
def update_lim(self, axes):
8891
pass
8992

93+
def get_nth_coord(self):
94+
return self.nth_coord
95+
9096
def _to_xy(self, values, const):
9197
"""
9298
Create a (*values.shape, 2)-shape array representing (x, y) pairs.
@@ -115,17 +121,13 @@ class _FixedAxisArtistHelperBase(_AxisArtistHelperBase):
115121
@_api.delete_parameter("3.9", "nth_coord")
116122
def __init__(self, loc, nth_coord=None):
117123
"""``nth_coord = 0``: x-axis; ``nth_coord = 1``: y-axis."""
118-
self.nth_coord = _api.check_getitem(
119-
{"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc)
124+
super().__init__(_api.check_getitem(
125+
{"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc))
120126
self._loc = loc
121127
self._pos = {"bottom": 0, "top": 1, "left": 0, "right": 1}[loc]
122-
super().__init__()
123128
# axis line in transAxes
124129
self._path = Path(self._to_xy((0, 1), const=self._pos))
125130

126-
def get_nth_coord(self):
127-
return self.nth_coord
128-
129131
# LINE
130132

131133
def get_line(self, axes):
@@ -158,12 +160,8 @@ def get_tick_transform(self, axes):
158160

159161
class _FloatingAxisArtistHelperBase(_AxisArtistHelperBase):
160162
def __init__(self, nth_coord, value):
161-
self.nth_coord = nth_coord
162163
self._value = value
163-
super().__init__()
164-
165-
def get_nth_coord(self):
166-
return self.nth_coord
164+
super().__init__(nth_coord)
167165

168166
def get_line(self, axes):
169167
raise RuntimeError("get_line method should be defined by the derived class")

0 commit comments

Comments
 (0)
0