Skip to content

Commit

Permalink
Fix inner axis visibility in relplot with unshared axes (#3180)
Browse files Browse the repository at this point in the history
* Fix inner axis visibility in relplot with unshared axes

* Don't reveal internal names when setting axis labels

* Better test name
  • Loading branch information
mwaskom committed Dec 10, 2022
1 parent c8badb9 commit 22cdfb0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/whatsnew/v0.12.2.rst
Expand Up @@ -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`).
3 changes: 2 additions & 1 deletion seaborn/relational.py
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_relational.py
Expand Up @@ -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(
Expand Down

0 comments on commit 22cdfb0

Please sign in to comment.