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: Enable xticklabels for all bottom axes #3600

Merged
merged 4 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions seaborn/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,8 @@ def _setup_figure(self, p: Plot, common: PlotData, layers: list[Layer]) -> None:
)
)
for group in ("major", "minor"):
side = {"x": "bottom", "y": "left"}[axis]
axis_obj.set_tick_params(**{f"label{side}": show_tick_labels})
for t in getattr(axis_obj, f"get_{group}ticklabels")():
t.set_visible(show_tick_labels)

Expand Down
12 changes: 12 additions & 0 deletions tests/_core/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,12 @@
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

Check warning on line 1860 in tests/_core/test_plot.py

View check run for this annotation

Codecov / codecov/patch

tests/_core/test_plot.py#L1860

Added line #L1860 was not covered by tests
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about how this is flagged as not tested since the pinned build log appears to have matplotlib 3.4 installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about this comment by codecov, but its webpage for this test suite suggests it is tested (lines marked as green). See here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the full code coverage report looks fine, not sure what's up with the bot.

assert all(t.get_visible() for t in ax.get_xticklabels())

for s in subplots[1:-1]:
Expand All @@ -1876,6 +1882,12 @@
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

Check warning on line 1890 in tests/_core/test_plot.py

View check run for this annotation

Codecov / codecov/patch

tests/_core/test_plot.py#L1890

Added line #L1890 was not covered by tests
assert all(t.get_visible() for t in ax.get_xticklabels())

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