-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: subfigure_mosaic #25949
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
Comments
I think this is a good first issue (limited API discussion as "match subplot_mosaic" is going to be the answer) and only affects a very limited part of the codebase. Labeling this as medium difficluty because the subplot_mosaic code is a bit complex (it supports infinite nesting of layouts via recursion) and some of the internal variables are not super clearly named (I named them). The source is: matplotlib/lib/matplotlib/figure.py Lines 1821 to 2128 in 82cfed3
On a cursory skim, I think that matplotlib/lib/matplotlib/figure.py Lines 2081 to 2087 in 82cfed3
_do_layout to take make_the_sub_thing as an input would work.
One maybe interesting question is that for nested layouts to we want to have sub-figures of sub-figures or flatten all of the sub-figures to be children of the Figure they are called on? I think the return has to be flat so I would lean towards the implementation also being flat (with the nesting in the spec being a details of the layout not an expression of actual nesting) and if the user does really want sub-figure of sub-figure they can call Tasks:
software estimate are notoriously hard, but I would guess 4-20 hours with a bulk of the time being in writing tests and docs. |
Flat would seem normal to me. |
Could I have a go at this? |
Hi @brandall25 - go ahead! Make sure you check our contributor guide and let us know if you have questions. Thanks! |
Hi @tacaswell, I have some questions about the tasks you laid out. When you say "refactor the layout logic into a private method", do you want that to be a private method of Also, I'm a bit confused by the Thanks! |
yes, or a class method, top level (private) function if it does not need any state. The main goal is to not have two copies of this somewhat long subtle code in the code base.
Yes, exactly that. The logic is "I need to add a sub-version of " which we can specify via dependency injection. |
@brandall25 Hi! Not sure I'm qualified to answer you here, but I've been working on this since last week and did just what you described for both of your questions. It seems to work. Edit: sorry, didn't see there was already an answer! @tacaswell should I make a PR for this? I didn't comment before because I wasn't sure I'd be able to do anything at all and then it was late. |
@turnipseason Hello, thanks for responding! Sounds like you have it covered, I think I'll move on to another issue. |
@brandall25 Hi! Sorry, I really should've written a comment earlier. Good luck with the other issues! |
@turnipseason Yes please to the PR. Adding to or mimicing https://github.com/matplotlib/matplotlib/blob/main/galleries/users_explain/axes/mosaic.py for sub-figures would probably make sense. You can use the same Alternatively looking https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/subfigures.html#figure-subfigures and using the "change the patch color" as a way to label the space (or both!) may be a good starting point for documentation inspiration. Similarly look at how |
also don't worry about the first draft being perfect, we expect iteration on PRs. |
Is the issue still open, or has the issue changed it would seem to me from the comment thread it has been resolved. |
@klorine28 There is an active PR addressing this issue (see cross reference right above your comment), I suggest you look for a different issue to work on. |
Problem
Recently I had a case of layouting subfigures where I could have benefitted from a subfigure_mosaic function, similar to subplot_mosaic.
Proposed solution
Provide subfigure_mosaic.
Bonus points if the implementation shares as much as possible with subplot_mosaic (I suspect we can just factor out everything and pass the "child-adding method" (fig.add_subplot or fig.add_subfigure) as a parameter to the internal implementation?).
The text was updated successfully, but these errors were encountered: