Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tick visibility introspection on matplotlib 3.10 #3802

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions tests/_core/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,17 @@ def test_labels(self, long_df):

class TestLabelVisibility:

def has_xaxis_labels(self, ax):
if _version_predates(mpl, "3.7"):
# mpl3.7 added a getter for tick params, but both yaxis and xaxis return
# the same entry of "labelleft" instead of "labelbottom" for xaxis
return len(ax.get_xticklabels()) > 0
elif _version_predates(mpl, "3.10"):
# Then I guess they made it labelbottom in 3.10?
return ax.xaxis.get_tick_params()["labelleft"]
else:
return ax.xaxis.get_tick_params()["labelbottom"]

def test_single_subplot(self, long_df):

x, y = "a", "z"
Expand Down Expand Up @@ -1852,12 +1863,7 @@ def test_1d_column_wrapped(self):
for s in subplots[1:]:
ax = s["ax"]
assert ax.xaxis.get_label().get_visible()
# mpl3.7 added a getter for tick params, but both yaxis and xaxis return
# the same entry of "labelleft" instead of "labelbottom" for xaxis
if not _version_predates(mpl, "3.7"):
assert ax.xaxis.get_tick_params()["labelleft"]
else:
assert len(ax.get_xticklabels()) > 0
assert self.has_xaxis_labels(ax)
assert all(t.get_visible() for t in ax.get_xticklabels())

for s in subplots[1:-1]:
Expand All @@ -1882,12 +1888,7 @@ def test_1d_row_wrapped(self):
for s in subplots[-2:]:
ax = s["ax"]
assert ax.xaxis.get_label().get_visible()
# mpl3.7 added a getter for tick params, but both yaxis and xaxis return
# the same entry of "labelleft" instead of "labelbottom" for xaxis
if not _version_predates(mpl, "3.7"):
assert ax.xaxis.get_tick_params()["labelleft"]
else:
assert len(ax.get_xticklabels()) > 0
assert self.has_xaxis_labels(ax)
assert all(t.get_visible() for t in ax.get_xticklabels())

for s in subplots[:-2]:
Expand Down
Loading