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

Update diagram in subplots_adjust documentation to clarify parameters#30029

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

Bindi003
Copy link

PR summary

This pull request addresses an issue in the documentation for where the diagram incorrectly implied that the left, right, top, and bottom parameters were distances from the nearest subplot edges. In reality, these parameters represent distances from the edges of the figure (the overall plotting area).

  • Why is this change necessary?
    The current diagram is misleading and contradicts the correct usage of subplots_adjust, potentially causing confusion for users trying to control subplot layout.

  • What is the reasoning for this implementation?
    The implementation involves updating the Python script (doc/_embedded_plots/figure_subplots_adjust.py) that generates the diagram embedded in the documentation. The plotting code has been modified to accurately represent the relationship between the subplots_adjust parameters and the figure edges, matching the function's actual behavior.

PR checklist

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@QuLogic
Copy link
Member

QuLogic commentedMay 9, 2025
edited
Loading

This appears incorrect:
image
The origin for all the parameters is the bottom left, not the top right.

@timhoffm
Copy link
Member

Yes should be something like thisimage

@Bindi003
Copy link
Author

Hi@QuLogic@timhoffm I've addressed the feedback on the diagram and pushed the updated code. Hopefully, it should now be correct. This is my first contribution, so I appreciate your guidance! Thank you!

@@ -17,14 +18,14 @@ def arrow(p1, p2, **props):

arrow((0, 0.75), (0.1, 0.75)) # left
arrow((0.435, 0.25), (0.565, 0.25)) # wspace
arrow((0.1, 0.8), (1, 0.8)) # right
arrow((0, 0.8), (0.9, 0.8)) # right
Copy link
Member

@story645story645May 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

looking at the function and function calls, I think the arrow function adds in an unncessary layer of indirection given that the only argument actually passed in is the point. I think here it would be a lot clearer to just do:

arrowprops=dict(arrowstyle="<->",shrinkA=0,shrinkB=0)xycoords='figure fraction'overlay.annotate("", (0,0.75), (0.1,0.75)),xycoords=xycoords,arrowprops=arrowprops)overlay.annotate("",(0.435,0.25), (0.565,0.25)  ,xycoords=xycoords,arrowprops=arrowprops)overlay.annotate("", (0,0.8), (0.9,0.8),xycoords=xycoords,arrowprops=arrowprops)

Copy link
Author

Choose a reason for hiding this comment

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

Hi@story645 , thanks for the suggestion! I've updated the code to use the direct overlay.annotate() calls as you recommended :)

Copy link
Member

Choose a reason for hiding this comment

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

@story645 I disagree. I intentionally introduced the arrow function as a semantic wrapper. I still findannotate("", xy1, xy2) a really awkward API. This is basically the discussion of#29826 (which is only deferred because we need to agree what the underlying artist should be), and the need for a reasonable high-level API still persists.

I'm not quite happy with reverting the wrapper, but since this is only an internal helper script and does not show up prominently in the docs, it's not worth fighting over.

Copy link
Member

@story645story645May 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

Sorry, but I also think doc examples are not the place to introduce new API. In this example, the extra arrow function to me felt very distracting once I figured out it wasn't doing anything extra. I would say here if anything then ConnectionPatch should just be used explicitly or thearrow function here should be wrapping ConnectionPatch.

Copy link
Member

Choose a reason for hiding this comment

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

This is not intoducing new API and the code is not user-facing or teaching by intent. In my perspective, it's just ahelper function making the examplemore readable for editors of that code. Obviously, YMMV. Let's not get into the discussion right now.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, is kinda how I read `intentionally introduced the arrow function as a semantic wrapper. I still find annotate("", xy1, xy2) a really awkward API."

@timhoffmtimhoffm modified the milestones:v3.10.4,v3.10-docMay 9, 2025
@timhoffmtimhoffm merged commitf7051b5 intomatplotlib:mainMay 9, 2025
22 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestMay 9, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestMay 9, 2025
@timhoffm
Copy link
Member

Thanks@Bindi003 and congratulations on your first contribution to Matplotlib 🎉! We'd be happy to see you again.

rcomer added a commit that referenced this pull requestMay 9, 2025
…029-on-v3.10.3-docBackport PR#30029 on branch v3.10.3-doc (Update diagram in subplots_adjust documentation to clarify parameters)
rcomer added a commit that referenced this pull requestMay 9, 2025
…029-on-v3.10.xBackport PR#30029 on branch v3.10.x (Update diagram in subplots_adjust documentation to clarify parameters)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@story645story645story645 left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.10-doc
Development

Successfully merging this pull request may close these issues.

[Doc]: matplotlib.figure.Figure.subplots_adjust figure
4 participants
@Bindi003@QuLogic@timhoffm@story645

[8]ページ先頭

©2009-2025 Movatter.jp