Skip to content

Add rcParams for figure.suptitle() kwargs (x, y, horizontalalignment, verticalalignment)#31889

Open
szzhoujiarui-sketch wants to merge 16 commits into
matplotlib:mainfrom
szzhoujiarui-sketch:fix/24090-suptitle-rcparams
Open

Add rcParams for figure.suptitle() kwargs (x, y, horizontalalignment, verticalalignment)#31889
szzhoujiarui-sketch wants to merge 16 commits into
matplotlib:mainfrom
szzhoujiarui-sketch:fix/24090-suptitle-rcparams

Conversation

@szzhoujiarui-sketch

Copy link
Copy Markdown

PR summary

Add rcParams for figure.suptitle() default kwargs (x, y, horizontalalignment, verticalalignment), as requested in #24090.

The new rcParams are:

  • figure.title_x (float, default: 0.5)
  • figure.title_y (float, default: 0.98)
  • figure.title_horizontalalignment (str in {'center', 'left', 'right'}, default: 'center')
  • figure.title_verticalalignment (str in {'top', 'center', 'bottom', 'baseline'}, default: 'top')

These follow the existing pattern used by axes.titlelocation (mpl._val_or_rc()). The _suplabels method now checks whether info['x0']/info['y0'] are strings (rcParams keys) or literals, so supxlabel/supylabel remain unaffected.

This only adds rcParams for suptitle; supxlabel and supylabel are left unchanged because they share figure.label_* keys but have different default positions (supxlabel y=0.01 vs supylabel y=0.5), which would create naming conflicts.

AI Disclosure

This PR was written with the assistance of AI (CodeBuddy agent). The AI was used to implement the code changes, write tests, and draft this PR description under the direction of the human author. All changes were reviewed and tested by the human author.

PR checklist

Release note

Add the following rcParams: figure.title_x, figure.title_y, figure.title_horizontalalignment, figure.title_verticalalignment. These control the default position and alignment of figure.suptitle().

@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 discourse chat 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.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[ENH]: Add default kwargs values if figure.suptitle(t, **kwargs) to rcParams and inherit from there.

1 participant