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

Support complex layouts in declarative interface using GridSpec and/or subplot_mosaic #1707

Open
jthielen opened this issue Feb 13, 2021 · 2 comments
Labels
Area: Plots Pertains to producing plots Type: Feature New functionality

Comments

@jthielen
Copy link
Collaborator

jthielen commented Feb 13, 2021

It's been a while, but I'm looking to try starting to use the declarative interface in my own work. One major sticking point that came up right away is how multi-panel figures are handled. Right now, it looks like only regular, even grids of panels/axes are supported by using the layout 3-tuple in each panel (so that they are added as subplots) and listing all the panels sequentially to the PanelContainer.

I use GridSpec a lot, so it would be nice to at least be able to set layout to be a SubplotSpec. However, seeing matplotlib's recent addition of subplot_mosaic makes me think that there could be an even more streamlined way to support complex figure layouts in the declarative interface. For example, if panels could be generalized from just being a list of panels, I could see something like the following:

pc = PanelContainer()
pc.size = (10, 10)
pc.panels = [
    [main_panel, side_panel_1],
    [main_panel, side_panel_2]
]

by using the nested list interface. Though, having main_panel show up twice to mean "this panel covers both these spaces" rather than "copy this panel in both these spaces" may not be intuitive for all users, so perhaps an alternate API for specifying this may be needed. Also, not sure what the string short-hand interface, or specifying the extra kwargs to subplot_mosaic would look like either.

In case a motivating example is desired, see https://unidata.github.io/MetPy/latest/examples/plots/Skew-T_Layout.html.

@jthielen jthielen added Type: Feature New functionality Area: Plots Pertains to producing plots labels Feb 13, 2021
@jthielen
Copy link
Collaborator Author

In going back through the issue tracker, a similar (but perhaps more simplified, focusing on just regular even grids) concern was brought up in #1016 (comment):

Layout of plots does not work as one might initially expect. Currently we set the layout attribute on a panel with a tuple of the location as in matplotlib. (1, 2, 2) While that behavior is fine, when adding panels to the panel container we just pass a simple list. It would be desirable to have the capability to not set the layout attribute and determine the layout by passing a list of lists. For example to layout a 2x2 figure it would be pc.panels = [[p1, p2], [p3, p4]].

@DanielAdriaansen
Copy link
Contributor

Just wanted to point out this complex layout I was able to achieve with the SkewT in MetPy, in case it's a useful example for further development or your work:

#1640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Plots Pertains to producing plots Type: Feature New functionality
Projects
None yet
Development

No branches or pull requests

2 participants