Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also allow Plot.label to control all paired axes #3459

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions seaborn/_core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,14 @@ def _extract_data(self, p: Plot) -> tuple[PlotData, list[Layer]]:

def _resolve_label(self, p: Plot, var: str, auto_label: str | None) -> str:

if re.match(r"[xy]\d+", var):
key = var if var in p._labels else var[0]
else:
key = var

label: str
if var in p._labels:
manual_label = p._labels[var]
if key in p._labels:
manual_label = p._labels[key]
if callable(manual_label) and auto_label is not None:
label = manual_label(auto_label)
else:
Expand Down
11 changes: 8 additions & 3 deletions tests/_core/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,14 @@ def test_limits(self, long_df):

def test_labels(self, long_df):

label = "Z"
p = Plot(long_df, y="y").pair(x=["x", "z"]).label(x1=label).plot()
ax1 = p._figure.axes[1]
label = "zed"
p = (
Plot(long_df, y="y")
.pair(x=["x", "z"])
.label(x=str.capitalize, x1=label)
)
ax0, ax1 = p.plot()._figure.axes
assert ax0.get_xlabel() == "X"
assert ax1.get_xlabel() == label


Expand Down
Loading