Skip to content

share='labels' is disabled after formatting individual subplots in UltraPlot 2.7.0 #833

Open

Description

@huddao

Question

Has the behavior of share='labels' with individual ax.format() calls changed between UltraPlot 2.5.0 and 2.7.0?

My existing multi-panel figure showed shared x/y labels with 2.5.0. After upgrading to 2.7.0, each subplot shows its own labels. I can reproduce the sharing-state change without my project code or data.

Minimal reproducible example

import ultraplot as uplt

fig, axs = uplt.subplots(
    [[1, 1], [2, 3], [4, 5]],
    share="labels",
)

print("Initially:", fig.get_axis_sharing())

axs[0].plot([0, 1], [1, 2])
axs[0].format(title="Total", ylabel="Value")

for i, ax in enumerate(axs[1:], 1):
    ax.plot([0, 1], [i, i + 1])
    ax.format(title=f"Panel {i}", xlabel="Year", ylabel="Value")

print("After formatting:", fig.get_axis_sharing())
fig.show()

Observed with 2.7.0

Immediately after subplots(), both x and y have level: 1 and labels: True. After the individual format() calls, both become level: 0 and labels: False; the spanning labels are disabled as well.

Expected behavior

I expected the identical axis-title strings to remain shared, as they appeared in my figure made with 2.5.0. Is this an intentional change? If so, what is the recommended migration for figures that set titles and other formatting on each subplot?

Formatting the common labels at figure/grid level appears to work around the problem, but I would like to understand whether the original usage should still be supported.

Environment

  • UltraPlot: 2.7.0
  • Python: 3.12.11
  • Matplotlib: 3.10.5
  • OS: Windows

I have not rerun this exact minimal example under 2.5.0; the 2.5.0 comparison is based on my previously generated figure.

Activity

  1. cvanelteren commented on Oct 2, 2026

    @cvanelteren
    Collaborator

    Yes it has. It is assumed that when you index into a specific axes you want to break sharing and it will update its own x/y label. This is caused by the x/y setter in the loop.

  2. cvanelteren commented on Oct 2, 2026

    @cvanelteren
    Collaborator

    The change is outlined here: #817

  3. cvanelteren commented on Oct 2, 2026

    @cvanelteren
    Collaborator

    not sure what you wanted to achieve but I think some of it is still possible as:

    fig, axs = uplt.subplots(
        [[1, 1], [2, 3], [4, 5]],
        # share="labels",
    )
    
    print("Initially:", fig.get_axis_sharing())
    
    axs[0].plot([0, 1], [1, 2])
    
    for idx, axi in enumerate(axs):
        axi.format(title=f"Panel{idx}")
    axs[2, :].format(xlabel="Year", ylabel="Value")
    
    print("After formatting:", fig.get_axis_sharing())
    fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions