Skip to content

Commit 45a098f

Browse files
authored
FIX: Enable xticklabels for all bottom axes (#3600)
* Test for xticklabels presence in bottom axes * Enable xticklabels for bottom axes * Correctly generalize ticklabel presence * satisfy linter
1 parent 2c115ed commit 45a098f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

seaborn/_core/plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,8 @@ def _setup_figure(self, p: Plot, common: PlotData, layers: list[Layer]) -> None:
11771177
)
11781178
)
11791179
for group in ("major", "minor"):
1180+
side = {"x": "bottom", "y": "left"}[axis]
1181+
axis_obj.set_tick_params(**{f"label{side}": show_tick_labels})
11801182
for t in getattr(axis_obj, f"get_{group}ticklabels")():
11811183
t.set_visible(show_tick_labels)
11821184

tests/_core/test_plot.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,12 @@ def test_1d_column_wrapped(self):
18521852
for s in subplots[1:]:
18531853
ax = s["ax"]
18541854
assert ax.xaxis.get_label().get_visible()
1855+
# mpl3.7 added a getter for tick params, but both yaxis and xaxis return
1856+
# the same entry of "labelleft" instead of "labelbottom" for xaxis
1857+
if not _version_predates(mpl, "3.7"):
1858+
assert ax.xaxis.get_tick_params()["labelleft"]
1859+
else:
1860+
assert len(ax.get_xticklabels()) > 0
18551861
assert all(t.get_visible() for t in ax.get_xticklabels())
18561862

18571863
for s in subplots[1:-1]:
@@ -1876,6 +1882,12 @@ def test_1d_row_wrapped(self):
18761882
for s in subplots[-2:]:
18771883
ax = s["ax"]
18781884
assert ax.xaxis.get_label().get_visible()
1885+
# mpl3.7 added a getter for tick params, but both yaxis and xaxis return
1886+
# the same entry of "labelleft" instead of "labelbottom" for xaxis
1887+
if not _version_predates(mpl, "3.7"):
1888+
assert ax.xaxis.get_tick_params()["labelleft"]
1889+
else:
1890+
assert len(ax.get_xticklabels()) > 0
18791891
assert all(t.get_visible() for t in ax.get_xticklabels())
18801892

18811893
for s in subplots[:-2]:

0 commit comments

Comments
 (0)