GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update diagram in subplots_adjust documentation to clarify parameters by Bindi003 · Pull Request #30029 · matplotlib/matplotlib

Conversation

@Bindi003

@Bindi003 Bindi003 commented May 9, 2025

Copy link
Copy Markdown

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

  • closes [Doc]: matplotlib.figure.Figure.subplots_adjust figure #30022 matplotlib.figure.Figure.subplots_adjust figure
  • [N/A ] new and changed code is tested
  • Plotting related features are demonstrated in figure_subplots_adjust.py
  • [N/A ] New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ellie
Update diagram in subplots_adjust documentation to clarify parameter …
ac52254
…meaning
github-actions[bot]
github-actions Bot reviewed May 9, 2025
View reviewed changes

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this 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 us on gitter for real-time discussion.

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@QuLogic

QuLogic commented May 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@timhoffm

timhoffm commented May 9, 2025

Copy link
Copy Markdown
Member

Yes should be something like this image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ellie
Corrected subplots_adjust diagram
dd7f51b
@Bindi003

Bindi003 commented May 9, 2025

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

story645
story645 reviewed May 9, 2025
View reviewed changes
Comment thread doc/_embedded_plots/figure_subplots_adjust.py Outdated
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

@story645 story645 May 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Bindi003 Bindi003 May 9, 2025

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

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 :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@timhoffm timhoffm May 9, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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 find annotate("", 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@story645 story645 May 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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 the arrow function here should be wrapping ConnectionPatch.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@timhoffm timhoffm May 9, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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 a helper function making the example more readable for editors of that code. Obviously, YMMV. Let's not get into the discussion right now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@story645 story645 May 9, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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."

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ellie
Addressed diagram feedback and simplified annotation calls
785140b
timhoffm
timhoffm approved these changes May 9, 2025
View reviewed changes
@timhoffm timhoffm modified the milestones: v3.10.4, v3.10-doc May 9, 2025
@timhoffm
timhoffm merged commit f7051b5 into matplotlib:main May 9, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 9, 2025
@timhoffm @meeseeksmachine
Backport PR matplotlib#30029: Update diagram in subplots_adjust docum…
ceb901c
…entation to clarify parameters
@meeseeksmachine meeseeksmachine mentioned this pull request May 9, 2025
Backport PR #30029 on branch v3.10.x (Update diagram in subplots_adjust documentation to clarify parameters) #30033
Merged
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 9, 2025
@timhoffm @meeseeksmachine
Backport PR matplotlib#30029: Update diagram in subplots_adjust docum…
d3c77af
…entation to clarify parameters
@meeseeksmachine meeseeksmachine mentioned this pull request May 9, 2025
Backport PR #30029 on branch v3.10.3-doc (Update diagram in subplots_adjust documentation to clarify parameters) #30034
Merged
@timhoffm

timhoffm commented May 9, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rcomer added a commit that referenced this pull request May 9, 2025
@rcomer
Merge pull request #30034 from meeseeksmachine/auto-backport-of-pr-30…
3d46cab
…029-on-v3.10.3-doc

Backport 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 request May 9, 2025
@rcomer
Merge pull request #30033 from meeseeksmachine/auto-backport-of-pr-30…
d397c52
…029-on-v3.10.x

Backport PR #30029 on branch v3.10.x (Update diagram in subplots_adjust documentation to clarify parameters)
@ksunden ksunden mentioned this pull request Aug 7, 2025
merge up v3.10.5 #30401
Merged
5 tasks
@ksunden ksunden mentioned this pull request Aug 30, 2025
merge up v3.10.6 #30491
Merged
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@story645 story645 story645 left review comments
@timhoffm timhoffm timhoffm approved these changes
@github-actions github-actions[bot] github-actions[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

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

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Bindi003 @QuLogic @timhoffm @story645
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.