8000 FIX: do not try to manage the visibility of un-drawn ticks · matplotlib/matplotlib@b2f9cec · GitHub
[go: up one dir, main page]

Skip to content

Commit b2f9cec

Browse files
committed
FIX: do not try to manage the visibility of un-drawn ticks
This reverts part of the changes from #13908 (in particular commit e908efe ) that tried to manage the visibility if the ticks that are not used. However, there was a bug in this that nothing would ever set ticks to be visible again. Because we currently cache / recycle ticks this meant that panning / zooming or resizing the figure would eventually lose ticks if the number of ticks ever went down and then back up. We could fix this by adding a `tick.set_visible(True)` for the drawn ticks, however this would break the (brittle) use case where users are reaching in and manually setting the visibility of individual ticks to False to hide them. Instead, we revert the consistency code altogether and accept that there will be `Tick` objects in `Axis.majorTicks` and `Axis.minorTicks` that are marked as visible, but are not drawn (because they are filtered by `_update_ticks`). Closes #14054
1 parent 6e49e89 commit b2f9cec

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

lib/matplotlib/axis.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,6 @@ def _update_ticks(self):
11231123
tick.set_label2(label)
11241124
ticks = [*major_ticks, *minor_ticks]
11251125

1126-
# mark the ticks that we will not be using as not visible
1127-
for t in (self.minorTicks[len(minor_locs):] +
1128-
self.majorTicks[len(major_locs):]):
1129-
t.set_visible(False)
1130-
11311126
view_low, view_high = self.get_view_interval()
11321127
if view_low > view_high:
11331128
view_low, view_high = view_high, view_low

lib/matplotlib/tests/test_ticker.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,3 @@ def test_remove_overlap(remove_overlapping_locs, expected_num):
963963
assert len(ax.xaxis.get_minor_ticks()) == expected_num
964964
assert len(ax.xaxis.get_minorticklabels()) == expected_num
965965
assert len(ax.xaxis.get_minorticklines()) == expected_num*2
966-
967-
# force a draw to call _update_ticks under the hood
968-
fig.canvas.draw()
969-
# check that the correct number of ticks report them selves as
970-
# visible
971-
assert sum(t.get_visible() for t in ax.xaxis.minorTicks) == expected_num

0 commit comments

Comments
 (0)
0