8000 In mpl_toolkits, use the same floating point slop as for standard ticks. · matplotlib/matplotlib@96ed497 · GitHub
[go: up one dir, main page]

Skip to content

Commit 96ed497

Browse files
committed
In mpl_toolkits, use the same floating point slop as for standard ticks.
Standard ticks use _interval_contains_close (in Axis._update_ticks); do the same in mpl_toolkits and deprecate the custom slops delta1, delta2 (if such knobs are really needed, we should try to have the same API in the main library anyways).
1 parent 29cc1b3 commit 96ed497

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``AxisArtistHelper.delta1`` and ``AxisArtistHelper.delta2``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated with no replacement.

lib/mpl_toolkits/axisartist/axislines.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import numpy as np
4343

44+
import matplotlib as mpl
4445
from matplotlib import _api, rcParams
4546
import matplotlib.axes as maxes
4647
from matplotlib.path import Path
@@ -98,12 +99,13 @@ def get_tick_iterators(self, axes):
9899

99100
class _Base:
100101
"""Base class for axis helper."""
101-
def __init__(self):
102-
self.delta1, self.delta2 = 0.00001, 0.00001
103102

104103
def update_lim(self, axes):
105104
pass
106105

106+
delta1 = _api.deprecated("3.6")(property(lambda self: 0.00001))
107+
delta2 = _api.deprecated("3.6")(property(lambda self: 0.00001))
108+
107109
class Fixed(_Base):
108110
"""Helper class for a fixed (in the axes coordinate) axis."""
109111

@@ -204,10 +206,7 @@ def __init__(self, axes, loc, nth_coord=None):
204206

205207
def get_tick_iterators(self, axes):
206208
"""tick_loc, tick_angle, tick_label"""
207-
208-
loc = self._loc
209-
210-
if loc in ["bottom", "top"]:
209+
if self._loc in ["bottom", "top"]:
211210
angle_normal, angle_tangent = 90, 0
212211
else:
213212
angle_normal, angle_tangent = 0, 90
@@ -224,15 +223,12 @@ def get_tick_iterators(self, axes):
224223

225224
def _f(locs, labels):
226225
for x, l in zip(locs, labels):
227-
228226
c = list(self.passthru_pt) # copy
229227
c[self.nth_coord] = x
230-
231228
# check if the tick point is inside axes
232229
c2 = tick_to_axes.transform(c)
233-
if (0 - self.delta1
234-
<= c2[self.nth_coord]
235-
<= 1 + self.delta2):
230+
if mpl.transforms._interval_contains_close(
231+
(0, 1), c2[self.nth_coord]):
236232
yield c, angle_normal, angle_tangent, l
237233

238234
return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)
@@ -304,9 +300,8 @@ def _f(locs, labels):
304300
c[self.nth_coord] = x
305301
c1, c2 = data_to_axes.transform(c)
306302
if (0 <= c1 <= 1 and 0 <= c2 <= 1
307-
and 0 - self.delta1
308-
<= [c1, c2][self.nth_coord]
309-
<= 1 + self.delta2):
303+
and mpl.transforms._interval_contains_close(
304+
(0, 1), [c1, c2][self.nth_coord])):
310305
yield c, angle_normal, angle_tangent, l
311306

312307
return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)

0 commit comments

Comments
 (0)
0