Skip to content

feat(figure): add loc parameter to suptitle - #32203

Open
Muhtasim-Munif-Fahim wants to merge 1 commit into
matplotlib:mainfrom
Muhtasim-Munif-Fahim:feat/suptitle-loc-param
Open

feat(figure): add loc parameter to suptitle#32203
Muhtasim-Munif-Fahim wants to merge 1 commit into
matplotlib:mainfrom
Muhtasim-Munif-Fahim:feat/suptitle-loc-param

Conversation

@Muhtasim-Munif-Fahim

Copy link
Copy Markdown

Problem

Closes #31339. \ ig.suptitle\ always centers its text; \�x.set_title\ has a \loc\ parameter but \ ig.suptitle\ does not, so users must reach into the text object to align super titles left or right.

Solution

Adds a \loc\ parameter to \ ig.suptitle()\ accepting 'left', 'center', 'right'\ (default 'center'\ for backward compatibility). \loc\ sets both the horizontal position and text alignment.

Implementation

  • \loc='left'\ -> x=0.02, ha='left'; 'center'\ -> x=0.5, ha='center'; 'right'\ -> x=0.98, ha='right'
  • Invalid values raise via _api.check_in_list\
  • \None\ default preserves existing centered behavior
  • Type stub updated; pyplot.suptitle inherits the parameter

Tests

Added \ est_suptitle_loc\ with 6 assertions covering all loc values, the default, and invalid input. All pass:

\
python -m pytest lib/matplotlib/tests/test_figure.py -k suptitle -v
\\

Risks

None for existing callers (default behavior unchanged).

Add loc parameter to ig.suptitle() supporting 'left', 'center', 'right' positions, defaulting to 'center' for backward compatibility. The loc parameter controls both the x-position and horizontal alignment of the super title text.
@QuLogic QuLogic added the ai-contribution PRs that are AI generated without a human in the loop label Aug 12, 2026
@melissawm melissawm added the status: autoclose candidate PRs that are not yet ready for review and may be automatically closed in two weeks label Aug 12, 2026
@github-actions

Copy link
Copy Markdown

⏰ This pull request might be automatically closed in two weeks from now.

Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable.

Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬

To increase the chance of a productive review:

As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code.

If you substantially improve this PR within two weeks, leave a comment and a team member may remove the status: autoclose candidate label and the PR stays open. Cosmetic changes or incomplete fixes will not be sufficient. Maintainers will assess improvements on their own schedule. Please do not ping (@) maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-contribution PRs that are AI generated without a human in the loop status: autoclose candidate PRs that are not yet ready for review and may be automatically closed in two weeks topic: figures and subfigures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: add loc parameter to the fig.suptitle()

3 participants