Skip to content

Improve legend loc and bbox_to_anchor documentation (#26620)#31422

Merged
timhoffm merged 3 commits into
matplotlib:mainfrom
amanparganiha:fix/legend-docs-26620
Mar 30, 2026
Merged

Improve legend loc and bbox_to_anchor documentation (#26620)#31422
timhoffm merged 3 commits into
matplotlib:mainfrom
amanparganiha:fix/legend-docs-26620

Conversation

@amanparganiha
Copy link
Copy Markdown
Contributor

PR summary

Fixes #26620 — Improves the loc and bbox_to_anchor parameter documentation in the legend module.

  • Why is this change necessary? The current loc documentation uses three separate paragraphs to describe legend positions, which is verbose and harder to scan. The bbox_to_anchor docs don't clearly state it's an advanced option or link to relevant guides.

  • What problem does it solve? Makes legend positioning easier to understand at a glance by adding a visual ASCII grid of all 9 positions, and clarifies the relationship between loc and bbox_to_anchor.

  • What is the reasoning for this implementation? Follows the suggestions in [Doc]: Improve legend loc and bbox_to_anchor documentation #26620 by maintainer @timhoffm.

Changes

  • Parameter loc: Replaced three text paragraphs with a concise explanation and an ASCII visual grid showing all 9 legend positions. Clarified that positions are within a bounding box configurable via bbox_to_anchor.
  • Parameter bbox_to_anchor: Clarified this is an advanced option for free placement. Added cross-references to Figure.legend for outside placement and to the :ref:legend_guide``.

AI Disclosure

I used Claude (Anthropic) for researching the issue and drafting the documentation text. The changes were reviewed and verified by me.

PR checklist

  • "closes [Doc]: Improve legend loc and bbox_to_anchor documentation #26620" is in the body of the PR description
  • [N/A] new and changed code is tested
  • [N/A] "Plotting related" features are demonstrated in an example
  • [N/A] "New Features" and "API Changes" are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

@github-actions
Copy link
Copy Markdown

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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

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.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

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

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Comment thread lib/matplotlib/legend.py Outdated
Comment thread lib/matplotlib/legend.py Outdated
amanparganiha and others added 2 commits March 30, 2026 13:41
@amanparganiha
Copy link
Copy Markdown
Contributor Author

Thanks for the review! Applied both suggestions.

@timhoffm timhoffm added this to the v3.11.0 milestone Mar 30, 2026
@timhoffm timhoffm merged commit 7820a63 into matplotlib:main Mar 30, 2026
38 of 41 checks passed
@amanparganiha amanparganiha deleted the fix/legend-docs-26620 branch April 26, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[Doc]: Improve legend loc and bbox_to_anchor documentation

2 participants