Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Do not pass gridspec_kw to inner layouts in subplot_mosaic#24189

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

joshbarrass
Copy link
Contributor

@joshbarrassjoshbarrass commentedOct 16, 2022
edited
Loading

PR Summary

Constructs a newgridspec_kw dictionary with the"width_ratios" and"height_ratios" removed, which is passed to the inner layouts instead of the original. This prevents an error from occurring when one of the inner layouts is not compatible with one of the specified ratios.

Thegridspec_kw arg when constructing a nested layout withsubplot_mosaic is no longer passed to any of the inner layouts. These args are generally not applicable to any of the inner layouts, and can cause exceptions to be raised in some cases (for example, the"width_ratios" and"height_ratios" cause an error when one of the nested layouts is not compatible with one of these ratios). More complex layouts should be constructed directly using.subfigure and.subplots.

Fixes#24099
Resubmission of#24188 with a more appropriate branch name.

Currently has one warning when building the docs, which will be fixed by#24190

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@joshbarrassjoshbarrass changed the titleDo not pass width_ratios or height_ratios to inner layouts in subplot_mosaicDo not pass gridspec_kw to inner layouts in subplot_mosaicOct 17, 2022
Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just some sorting suggestions that you can argue for or against.

@jklymak
Copy link
Member

Sorry

home/circleci/project/lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:49: WARNING: py:obj reference target not found: subfigure/home/circleci/project/lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:49: WARNING: py:obj reference target not found: subfigure/home/circleci/project/lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure:49: WARNING: py:obj reference target not found: subfigure/home/circleci/project/doc/api/next_api_changes/behavior/24189-JB.rst:4: WARNING: py:obj reference target not found: Figure.subfigure

Sorry, should have been.Figure.subfigures I think...

@joshbarrass
Copy link
ContributorAuthor

@jklymak I've updated those lines to.Figure.subfigures now. Fingers crossed everything works now (:

@tacaswelltacaswell added this to thev3.7.0 milestoneOct 19, 2022
@tacaswell
Copy link
Member

Are there any uses of passing things through that will now be broken?

I do not think this in the right fix as the issue here is that the height and width ratios are being passed through not generic gridspec kwargs. I think instead we should not merge the two ratio into the user supplied dictionary and only use those at the top level and let the user suppliedgridspec_kw dictionary still flow all the way through as there are other keywords that you would want to thread through that do not depend on exactly matching the shape of the layout.

More complex layouts should be constructed directly using .subfigure and .subplots.

I do not agree with this and this were a case, we should rip out all of the recursive logic insubplot_mosaic.

tacaswell
tacaswell previously requested changesOct 19, 2022
Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this is making too big of a change and we can instead not pass through the independently specified ratios.

@jklymak
Copy link
Member

as there are other keywords that you would want to thread through that do not depend on exactly matching the shape of the layout.

That was discussed above - what is left arew/hspace,left/top etc. Is there really a case where a user has set these, and also expects the same values to be passed down to lower levels? These are all passed in figure-relative units, so they will all halve in physical size at lower levels. It would be a pretty fortuitous layout that wanted this.

More complex layouts should be constructed directly using .subfigure and .subplots.

I do not agree with this and this were a case, we should rip out all of the recursive logic in subplot_mosaic.

Almost all the subplot mosaic calls I've seen are made withlayout='constrained' which ignoresw/hspace,left/top etc. anyhow. So unless we want to allow the user to have a nested set of gridspec_kws I think the current proposal is the cleanest.

BTW, the above should read: More complex layouts should be constructed directly using .subfigure and .subplots or .subplot_mosaic. You can still use subplot_mosaic on the subfigure.

@tacaswell
Copy link
Member

That was discussed above - what is left are w/hspace, left/top

Sorry, I did not unfold and read the in-line discussion and was just reacting to the current state of the PR. I now see that there was extensive discussion in them.

I find the argument that none of these arguments make sense recursively (and passing them through at all was a mistake (that is my fault)). I think this should be made clearer in the deprecation note as now it reads (to me) like "This works most of the time but we are going to break it because it does not work in some corner cases".

I'm of bit of a mind to deprecategridspec_kw all together I think that is worse (it breaks the rhyming withfig.subplots).


@joshbarrass Sorry for over-reacting a bit on your first PR, I assure you it is not personal.

@tacaswelltacaswell dismissed theirstale reviewOctober 20, 2022 16:58

I did not read enough context and over-reacted. Would still like the deprecation message to be a worded a bit more strongly, but will not block over that.

@joshbarrass
Copy link
ContributorAuthor

No problem@tacaswell. I can totally understand where you are coming from, particularly as I originally drafted this PR that way (:

I've updated the message to reflect the discussion, that the behaviour is being changed because it is rarely appropriate for these arguments to be passed to the inner layouts. Does this make the reasoning for the change clearer in everyone's opinions?

Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@tacaswelltacaswell merged commit3a5c6dc intomatplotlib:mainOct 21, 2022
@tacaswell
Copy link
Member

I squashed merged this to keep the history a bit cleaner.


Thank you for you work@joshbarrass and congratulations on your first merged Matplotlib PR 🎉 Hopefully we will hear from you again!

melissawm pushed a commit to melissawm/matplotlib that referenced this pull requestDec 19, 2022
…b#24189)* Do not pass width/height ratios to nested layoutsCo-authored-by: Jody Klymak <jklymak@gmail.com>Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@tacaswelltacaswelltacaswell left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

[Bug]: Error using width_ratios with nested mosaic in subplot_mosaic()
4 participants
@joshbarrass@jklymak@tacaswell@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp