From f00e31dfe79ec1679a526b5c88b8d86aaa86cfd9 Mon Sep 17 00:00:00 2001 From: Maoz Gelbart <13831112+MaozGelbart@users.noreply.github.com> Date: Mon, 20 May 2024 09:05:57 +0300 Subject: [PATCH] Infer label position from target axis --- seaborn/_core/plot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/seaborn/_core/plot.py b/seaborn/_core/plot.py index c9dc61c8a7..9e4b8ff699 100644 --- a/seaborn/_core/plot.py +++ b/seaborn/_core/plot.py @@ -1154,7 +1154,8 @@ def _setup_figure(self, p: Plot, common: PlotData, layers: list[Layer]) -> None: # axis / tick labels can be shown on interior shared axes if desired axis_obj = getattr(ax, f"{axis}axis") - visible_side = {"x": "bottom", "y": "left"}.get(axis) + # This allows correct handling for twin{x/y} axises (GH 3614) + visible_side = axis_obj.get_label_position() show_axis_label = ( sub[visible_side] or not p._pair_spec.get("cross", True) @@ -1172,8 +1173,9 @@ 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}) + axis_obj.set_tick_params( + **{f"label{visible_side}": show_tick_labels} + ) for t in getattr(axis_obj, f"get_{group}ticklabels")(): t.set_visible(show_tick_labels)