Skip to content

Inconsistent behavior of axis label sharing #348

Closed

Description

@syrte

According to doc of ultraplot.subplots (or ultraplot.Figure), there are four levels of axis sharing.

  • 0 or False: No axis sharing. This also sets the default spanx and spany values to False.

  • 1 or 'labels' or 'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.

  • 2 or 'limits' or 'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.

  • 3 or True: As above but only show the tick labels on the bottommost row and leftmost column of subplots.

  • 4 or 'all': As above but also share the axis limits, scales, and tick locations between subplots not in the same row or column.

However, I found that ultraplot does not respect this convention exactly in ultraplot=1.60.2.
For example, share=1, share="labs", share=labels do not provide the expected behavior (though these options do provide identical results).
Here is a minimum example:

%matplotlib
import ultraplot as uplt
fig, axs = uplt.subplots(None, 2, 3, sharey='labels')
axs.format(ylabel='PDF')

fig, axs = uplt.subplots(None, 2, 3, sharey='labs')
axs.format(ylabel='PDF')

fig, axs = uplt.subplots(None, 2, 3, sharey=1)
axs.format(ylabel='PDF')

In contrast, ultraplot=1.50 works as expected (left panels in screenshot below).

Image

However, interestingly, I notice that the example in userguide using uplt.figure works as expected.
So there seems an inconsistency between uplt.subplots and Figure.subplots?

BTW, also note that in the user guide, point 3 does not provide the full list of the five available options (compare to proplot), though it says "five" just above the list.
Is this change intentional or a misoperation?

Activity

  1. cvanelteren commented on Sep 16, 2025

    @cvanelteren
    Collaborator

    You are correct. I inadvertently caused breaking behavior. I replaced the sharing algorithm as the previous method did not allow for top right sharing but inadvertently broke the 2nd sharing level (labels).

    Not sure exactly what happened with the docs as that is not intended.

    Will need to address both -- apologies for the inconvenience.

  2. cvanelteren commented on Sep 16, 2025

    @cvanelteren
    Collaborator

    The commit that broke things is 8f66423

    I can see the docs were updated but nothing was removed just added.

  3. self-assigned this
    on Sep 16, 2025
  4. cvanelteren commented on Sep 16, 2025

    @cvanelteren
    Collaborator

    @syrte can you confirm that you are running mpl <3.10?

  5. cvanelteren commented on Sep 16, 2025

    @cvanelteren
    Collaborator

    In essence I went on a little exploration spree but I am getting this:

    Image Image Image
    Code
    import ultraplot as uplt, numpy as np
    
    for sharing in [0, "labels", "labs", 1, True]:
        fig, ax = uplt.subplots(
            nrows=2,
            ncols=3,
            sharey=sharing,
            journal="nat1",
        )
        for idx, axi in enumerate(ax):
            d = np.random.rand(2, 10) * (idx + 1)
            axi.plot(*d)
        ax.format(suptitle=f"sharey={sharing}")
    uplt.show(block=1)
  6. cvanelteren commented on Sep 16, 2025

    @cvanelteren
    Collaborator

    Which I think is correct or am I missing it (it's a bit late here now ;-)).

  7. syrte commented on Sep 17, 2025

    @syrte
    ContributorAuthor

    @syrte can you confirm that you are running mpl <3.10?

    I am using
    mpl 3.10.6 with uplt 1.6
    mpl 3.9.4 with uplt 1.5

    I didn't set the mpl version explicitly. It is what I have.

  8. cvanelteren commented on Sep 17, 2025

    @cvanelteren
    Collaborator

    Thanks! There is indeed a minor change with mpl 3.9, but I don't think that was the original issue.

    The plots above a generated from the PR and I believe is how they should look.

  9. cvanelteren commented on Sep 17, 2025

    @cvanelteren
    Collaborator

    Note I checked with the labels and they are shared accordingly.

  10. cvanelteren commented on Oct 25, 2025

    @cvanelteren
    Collaborator

    Should be fixed on main @syrte; feel free to close when ready and or please list any issue you are still experiencing.

  11. syrte commented on Nov 24, 2025

    @syrte
    ContributorAuthor

    many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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