diff --git a/doc/whatsnew/v0.12.2.rst b/doc/whatsnew/v0.12.2.rst index da1d8b816b..8eeb8f1990 100644 --- a/doc/whatsnew/v0.12.2.rst +++ b/doc/whatsnew/v0.12.2.rst @@ -9,3 +9,5 @@ v0.12.2 (Unreleased) - |Fix| Fixed a regression in v0.12.0 where manually-added labels could have duplicate legend entries (:pr:`3116`). - |Fix| Fixed a bug in :func:`histplot` with `kde=True` and `log_scale=True` where the curve was not scaled properly (:pr:`3173`). + +- |Fix| Fixed a bug in :func:`relplot` where inner axis labels would be shown when axis sharing was disabled (:pr:`3180`). diff --git a/seaborn/relational.py b/seaborn/relational.py index 4fa854a630..18e18bb64c 100644 --- a/seaborn/relational.py +++ b/seaborn/relational.py @@ -955,7 +955,8 @@ def relplot( g.map_dataframe(func, **plot_kws) # Label the axes, using the original variables - g.set(xlabel=variables.get("x"), ylabel=variables.get("y")) + # Pass "" when the variable name is None to overwrite internal variables + g.set_axis_labels(variables.get("x") or "", variables.get("y") or "") # Show the legend if legend: diff --git a/tests/test_relational.py b/tests/test_relational.py index eee12e25b3..b100f4ecac 100644 --- a/tests/test_relational.py +++ b/tests/test_relational.py @@ -624,6 +624,23 @@ def test_relplot_legend(self, long_df): for line, color in zip(lines, palette): assert line.get_color() == color + def test_relplot_unshared_axis_labels(self, long_df): + + col, row = "a", "b" + g = relplot( + data=long_df, x="x", y="y", col=col, row=row, + facet_kws=dict(sharex=False, sharey=False), + ) + + for ax in g.axes[-1, :].flat: + assert ax.get_xlabel() == "x" + for ax in g.axes[:-1, :].flat: + assert ax.get_xlabel() == "" + for ax in g.axes[:, 0].flat: + assert ax.get_ylabel() == "y" + for ax in g.axes[:, 1:].flat: + assert ax.get_ylabel() == "" + def test_relplot_data(self, long_df): g = relplot(