Skip to content

feat: add rcParams for suptitle alignment#31767

Closed
RichardHopperProGrammar wants to merge 1 commit into
matplotlib:mainfrom
RichardHopperProGrammar:rcparam-suptitle-kwargs
Closed

feat: add rcParams for suptitle alignment#31767
RichardHopperProGrammar wants to merge 1 commit into
matplotlib:mainfrom
RichardHopperProGrammar:rcparam-suptitle-kwargs

Conversation

@RichardHopperProGrammar
Copy link
Copy Markdown

Add figure.titlehorizontalalign and figure.titleverticalalign rcParams

Fixes #24090

Problem

suptitle() defaults for horizontal and vertical alignment were hardcoded (center / top). Only fontsize and fontweight were configurable via rcParams. Users who wanted to control suptitle alignment had to call suptitle(ha=..., va=...) every time — no way to set a project-wide default via rc settings.

Solution

Added two new rcParams:

  • figure.titlehorizontalalign (default: "center") — validates against {center, left, right, center_left, center_right}
  • figure.titleverticalalign (default: "top") — validates against standard vertical alignments
import matplotlib.pyplot as plt

plt.rcParams[figure.titlehorizontalalign] = left
plt.rcParams[figure.titleverticalalign] = bottom

fig, ax = plt.subplots()
fig.suptitle("Left-aligned title")  # Uses rcParams defaults
fig.suptitle("Override", ha=right)  # Explicit kwarg still wins

Changes

  • rcsetup.py: Added validate_suptitle_ha validator + two new rcParam entries with defaults
  • figure.py: Updated _suplabels() to resolve ha/va from rcParams when the key is set
  • matplotlibrc: Added commented-out default values for the new params
  • tests/test_figure.py: Two new tests — rcParams alignment applies, kwarg overrides work
  • typing.py: Added new keys to RcKeyType enum

Backwards Compatibility

Fully backwards compatible. Default values match the old hardcoded defaults (center / top). Existing code that passes explicit ha/va kwargs is unaffected.

Add 'figure.titlehorizontalalign' and 'figure.titleverticalalign' rcParams
so that users can control the default alignment of figure titles via rc settings.

Before:
  Only fontsize and fontweight were configurable via rcParams; ha/va were
  hardcoded to 'center'/'top'.

After:
  rcParams['figure.titlehorizontalalign'] defaults to 'center'
  rcParams['figure.titleverticalalign'] defaults to 'top'
  Explicit suptitle() kwargs still override rcParam defaults.

- Added validate_suptitle_ha validator in rcsetup.py
- Updated figure._suplabels to resolve ha/va from rcParams when set
- Updated matplotlibrc with new default entries
- Added 2 tests: rcParams alignment and kwarg override
- Updated docstring to reference new rcParams
@timhoffm
Copy link
Copy Markdown
Member

Thanks for the interest in contributing.

However, the PR does not meet our quality standards: It doesn't use the PR template, it doesn't reflect the state of discussion, e.g. naming (#24090 (comment)), I suspect violoation of our AI policy.

On a general note: You have opened 8 PRs on 8 different projects within a day. This is not a valuable way of contributing to open source. Either AI has done most or all of the work, which - if desired at all - is better be controlled by project mantainers and not random external contributors, or you as a human try to seriously engage with seveal projects at once, which is a waste of resources.

@timhoffm timhoffm closed this May 28, 2026
@timhoffm timhoffm added the ai-contribution PRs that are AI generated without a human in the loop label May 28, 2026
@RichardHopperProGrammar
Copy link
Copy Markdown
Author

Thanks for the feedback, @timhoffm. I've opened a replacement PR (#31768) with:

Appreciate you taking the time to review.

@RichardHopperProGrammar
Copy link
Copy Markdown
Author

Thanks for the feedback, @timhoffm. I have opened a replacement PR (#31768) with:

Appreciate you taking the time to review.

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 topic: figures and subfigures topic: rcparams

Projects

None yet

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.

3 participants