Skip to content

[Feature request] span axis labels #464

Open

Description

@cvanelteren

Description

I often have the issue where the axes are not shared, but I do want to share the labels. For example when I am mixing some axes and not others. I propose to add a feature where you can specify the sharing of the axis. As far as I am aware this is not available in proplot. Currently I resort to something like

def add_main(fig, nrows, ncols, span):
 main = fig.add_subplot(nrows, ncols, span)
 main.set_facecolor("none")
 main.set_xticks([])
 main.set_yticks([])
 for spine in main.axes.spines.values():
     spine.set_visible(False)
 return main

fig, ax = plt.subplots(ncols = 2, nrows = 2, share = 0)
main_top = add_main(fig, 2, 2, (1, 2))
main_top.set_xlabel("group 1", labelpad = 25)
main_top.set_ylabel("group 1", labelpad = 25)


main_bottom = add_main(fig, 2, 2, (3, 4))
main_bottom.set_xlabel("group 2", labelpad = 25)
main_bottom.set_ylabel("group 2", labelpad = 25)

fig.show()

Resulting in
image

Some of it can be achieved with fig labels. If this can already be achieved, we could add it to the docs, if not we can add it.

Activity

  1. syrte commented on Oct 21, 2024

    @syrte

    Try this:

    fig, axs = pplt.subplots(nrows=2, ncols=2, sharex=False, spanx=True)
    axs[0].format(xlabel='row1')
    axs[2].format(xlabel='row2')
    
    image

    I believe this is what you are looking for.

  2. cvanelteren commented on Oct 21, 2024

    @cvanelteren
    Author

    Ideally I would like to format subfigures. What I am getting at is how would I get a spanning label for this:

    import proplot as plt
    
    layout = [
        [1, 2, 5],
        [3, 4, 5]
    ]
    
    fig, ax = plt.subplots(layout, sharex = True, figsize = (5,3))
    ax[:4].format(xlabel = "grouped label")
    ax[-1].format(xlabel = "separate label")
    

    image

  3. cvanelteren commented on Oct 21, 2024

    @cvanelteren
    Author

    It would be ideal if we could index into the axis that I wish to format and making them shared in a smart way without having it apply to all subplots. The work around is to make everything manually fit where you can overlay dummy axes -- but this gets pretty complicated as the complexity of the graph grows, but in principle is possible.

  4. KingRyu1998 commented on Dec 9, 2024

    @KingRyu1998

    helpful examples, appreciate it

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