proplot icon indicating copy to clipboard operation
proplot copied to clipboard

[Feature request] span axis labels

Open cvanelteren opened this issue 1 year ago • 4 comments

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.

cvanelteren avatar Aug 26 '24 08:08 cvanelteren

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.

syrte avatar Oct 21 '24 03:10 syrte

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 avatar Oct 21 '24 09:10 cvanelteren

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.

cvanelteren avatar Oct 21 '24 09:10 cvanelteren

helpful examples, appreciate it

KingRyu1998 avatar Dec 09 '24 07:12 KingRyu1998