Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] span axis labels #464

Open
cvanelteren opened this issue Aug 26, 2024 · 4 comments
Open

[Feature request] span axis labels #464

cvanelteren opened this issue Aug 26, 2024 · 4 comments

Comments

@cvanelteren
Copy link

cvanelteren commented Aug 26, 2024

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.

@syrte
Copy link

syrte commented Oct 21, 2024

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.

@cvanelteren
Copy link
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

@cvanelteren
Copy link
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.

@KingRyu1998
Copy link

helpful examples, appreciate it

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

No branches or pull requests

3 participants