Skip to content

Commit

Permalink
FIX: Enable xticklabels for all bottom axes (#3600)
Browse files Browse the repository at this point in the history
* Test for xticklabels presence in bottom axes

* Enable xticklabels for bottom axes

* Correctly generalize ticklabel presence

* satisfy linter
  • Loading branch information
MaozGelbart authored Dec 28, 2023
1 parent 2c115ed commit 45a098f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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 @@ 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 all(t.get_visible() for t in ax.get_xticklabels())

for s in subplots[1:-1]:
Expand All @@ -1876,6 +1882,12 @@ 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 all(t.get_visible() for t in ax.get_xticklabels())

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

0 comments on commit 45a098f

Please sign in to comment.