Add rcParams for figure.suptitle() kwargs (x, y, horizontalalignment, verticalalignment)#31889
Conversation
… alignment rcParams
…label with literal defaults
|
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. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
The _suplabels docstring is shared by suptitle, supxlabel, and supylabel. Using :rc: for x/y/ha/va substitutions breaks for supxlabel/supylabel because their substitution values are literals (e.g., 'center', 0.5), not valid rcParams keys, causing Sphinx build failures. Also add comprehensive tests: - Regression tests for supxlabel/supylabel defaults - Test all valid alignment combinations for suptitle rcParams
Change TestSpectral.stim to @classmethod and use cls parameter directly instead of request.cls, following pytest 10 deprecation of instance-based class-scoped fixtures.
This comment was marked as low quality.
This comment was marked as low quality.
|
Hi @szzhoujiarui-sketch and thank you for your contribution. General points about PR presentationPlease revert the changes in I have hidden your above comment because I do not think it is useful to reviewers. Reviewers have limited amounts of time so do not really want to read through anything that doesn’t help us evaluate your change. In particular
Unnecessary information in comments is often a sign that they were written by AI. Please read our policy on that. Specific point about this changeI think Jody’s question at #24090 (comment) still needs addressing. Do you have any thoughts on that? |
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_suplabelsmethod now checks whetherinfo['x0']/info['y0']are strings (rcParams keys) or literals, sosupxlabel/supylabelremain unaffected.This only adds rcParams for
suptitle;supxlabelandsupylabelare left unchanged because they sharefigure.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 offigure.suptitle().