Skip to content

Fix share label group overrides - #473

Merged
cvanelteren merged 2 commits into
mainfrom
fix/share-label-groups
Jan 15, 2026
Merged

Fix share label group overrides#473
cvanelteren merged 2 commits into
mainfrom
fix/share-label-groups

Conversation

@cvanelteren

Copy link
Copy Markdown
Collaborator

Fix share‑label group precedence so explicit groups are the sole source of spanning labels and avoid mis‑anchored labels when mixed layouts are used, while also clearing share‑label groups on full‑grid axs.format(xlabel=...) to make global overrides deterministic; add regression tests covering subgroup labels vs global overrides.

image
import numpy as np

import ultraplot as uplt

rng = np.random.default_rng(21)
x = np.linspace(0, 5, 300)

layout = [[1, 2, 5], [3, 4, 5]]
# layout = [[1, 2], [4, 4]]
fig, axs = uplt.subplots(layout, journal="nat1")
for i, ax in enumerate(axs):
    trend = (i + 1) * 0.2
    y = np.exp(-0.4 * x) * np.sin(2 * x + i * 0.6) + trend
    y += 0.05 * rng.standard_normal(x.size)
    ax.plot(x, y, lw=2)
    ax.fill_between(x, y - 0.15, y + 0.15, alpha=0.2)
    ax.set_title(f"Condition {i + 1}")
# Share first 2 plots top left
axs[:2].format(
    xlabel="Time (days)",
)
axs[1, :2].format(xlabel="Time 2 (days)")
axs[[-1]].format(xlabel="Time 3 (days)")
axs.format(
    ylabel="Normalized response",
    abc=True,
    abcloc="ul",
    suptitle="Spanning labels with shared axes",
    grid=False,
)
axs.format(abc=1, abcloc="ol")

@codecov

codecov Bot commented Jan 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/figure.py 64.70% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren
cvanelteren merged commit facda2c into main Jan 15, 2026
2 of 3 checks passed
@cvanelteren
cvanelteren deleted the fix/share-label-groups branch January 15, 2026 10:00
@cvanelteren
cvanelteren restored the fix/share-label-groups branch January 15, 2026 10:00
@cvanelteren
cvanelteren deleted the fix/share-label-groups branch January 15, 2026 10:00
cvanelteren added a commit that referenced this pull request Jan 16, 2026
K-Mirembe-Mercy pushed a commit to K-Mirembe-Mercy/UltraPlot that referenced this pull request Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant