Skip to content

Commit 83ae531

Browse files
FBumannclaude
andcommitted
fix: disambiguation condition and stale comment
- Only disambiguate labels when all are non-empty and identical, preventing spurious suffixes when mixing named and unnamed figures - Update stale make_subplots comment in test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0cb6e6d commit 83ae531

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tests/test_figures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def test_titles_from_yaxis_label(self) -> None:
867867

868868
def test_titles_fallback_empty(self) -> None:
869869
grid = subplots(go.Figure(), go.Figure(), cols=2)
870-
# make_subplots omits annotations for empty titles
870+
# No annotations are created for empty titles
871871
titles = [ann.text for ann in grid.layout.annotations]
872872
assert titles == []
873873

xarray_plotly/figures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def _ensure_legend_visibility(
5656
# --- Step 1: label unnamed traces from source y-axis titles -----------
5757
labels = [_get_yaxis_title(f) for f in source_figs]
5858

59-
# If all labels are the same, disambiguate
59+
# If all labels are non-empty and identical, disambiguate
6060
unique_labels = {lb for lb in labels if lb}
61-
if len(unique_labels) == 1:
61+
if len(unique_labels) == 1 and all(lb for lb in labels):
6262
labels = [f"{labels[0]} ({i + 1})" for i in range(len(labels))]
6363

6464
for label, sl in zip(labels, trace_slices, strict=False):

0 commit comments

Comments
 (0)