From b2f9cec6b02204b0e5b964b0ac385a54c624afa2 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 26 Apr 2019 13:30:31 -0400 Subject: [PATCH] FIX: do not try to manage the visibility of un-drawn ticks This reverts part of the changes from #13908 (in particular commit e908efe37131da0697bd8e9c62444d37b4940ad3 ) 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 --- lib/matplotlib/axis.py | 5 ----- lib/matplotlib/tests/test_ticker.py | 6 ------ 2 files changed, 11 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 5f462860bd3d..477d0305b669 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -1123,11 +1123,6 @@ def _update_ticks(self): tick.set_label2(label) ticks = [*major_ticks, *minor_ticks] - # mark the ticks that we will not be using as not visible - for t in (self.minorTicks[len(minor_locs):] + - self.majorTicks[len(major_locs):]): - t.set_visible(False) - view_low, view_high = self.get_view_interval() if view_low > view_high: view_low, view_high = view_high, view_low diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 8c52fc9dde9b..486668967e97 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -963,9 +963,3 @@ def test_remove_overlap(remove_overlapping_locs, expected_num): assert len(ax.xaxis.get_minor_ticks()) == expected_num assert len(ax.xaxis.get_minorticklabels()) == expected_num assert len(ax.xaxis.get_minorticklines()) == expected_num*2 - - # force a draw to call _update_ticks under the hood - fig.canvas.draw() - # check that the correct number of ticks report them selves as - # visible - assert sum(t.get_visible() for t in ax.xaxis.minorTicks) == expected_num pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy