8000 ENH: add flag to disable locator 'de-confliction' · matplotlib/matplotlib@e3a8393 · GitHub
[go: up one dir, main page]

Skip to content

Commit e3a8393

Browse files
committed
ENH: add flag to disable locator 'de-confliction'
If Axis.remove_overlapping_locs is set to False the `Axis` object will not attempt to remove locations in the minor ticker that overlap with locations in the major ticker. This is a follow up to #13314 which un-conditionally removed the overlap. closes #13618
1 parent 8d4cee5 commit e3a8393

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/matplotlib/axis.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,8 @@ def __init__(self, axes, pickradius=15):
723723
`.Axis.contains`.
724724
"""
725725
martist.Artist.__init__(self)
726+
self._remove_overlapping_locs = True
727+
726728
self.set_figure(axes.figure)
727729

728730
self.isDefault_label = True
@@ -754,6 +756,17 @@ def __init__(self, axes, pickradius=15):
754756
majorTicks = _LazyTickList(major=True)
755757
minorTicks = _LazyTickList(major=False)
756758

759+
def get_remove_overlapping_locs(self):
760+
return self._remove_overlapping_locs
761+
762+
def set_remove_overlapping_locs(self, val):
763+
self._remove_overlapping_locs = bool(val)
764+
765+
remove_overlapping_locs = property(
766+
get_remove_overlapping_locs, set_remove_overlapping_locs,
767+
doc=('If minor ticker locations that overlap with major '
768+
'ticker locations should be trimmed.'))
769+
757770
def set_label_coords(self, x, y, transform=None):
758771
"""
759772
Set the coordinates of the label.
@@ -1323,9 +1336,10 @@ def get_minorticklocs(self):
13231336
# Use the transformed view limits as scale. 1e-5 is the default rtol
13241337
# for np.isclose.
13251338
tol = (hi - lo) * 1e-5
1326-
minor_locs = [
1327-
loc for loc, tr_loc in zip(minor_locs, tr_minor_locs)
1328-
if not np.isclose(tr_loc, tr_major_locs, atol=tol, rtol=0).any()]
1339+
if self.remove_overlapping_locs:
1340+
minor_locs = [
1341+
loc for loc, tr_loc in zip(minor_locs, tr_minor_locs)
1342+
if ~np.isclose(tr_loc, tr_major_locs, atol=tol, rtol=0).any()]
13291343
return minor_locs
13301344

13311345
def get_ticklocs(self, minor=False):

0 commit comments

Comments
 (0)
0