You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH]: Add default kwargs values if figure.suptitle(t, **kwargs) to rcParams and inherit from there. #24090
I cannot change the default location of a figure.suptitle() through the rcParams as I can with the title location of the axis title.
Origin/background
I am tweaking the default settings of Matplotlib to create plots that in appearance match the corporate styling. Most changes have been made by re-setting the default values of certain rcParams.
One of the requirements is the left-alignment of titles of graphs. For the axis title I can set rcParams['axes.titlelocation'] to 'left', as itdefaults to center. I would like to do something similar to the figure's suptitle.
Currently, setting the figure's suptitle only takes defaults rcParams['figure.titlesize'] and rcParams['figure.titleweight']. The other parameters for location and alignment of the suptitle are defaulted in the method's argument definition. My desire is to add these to rcParams as well, and refer hereto as default.
And then use these defaults in figure.suptitle(), very similar to how rcParams['figure.titlesize'] and rcParams['figure.titleweight'] are already used as default values.
I think this is a good first issue because there is limited API choices to be made and there are good examples of merged PRs adding rcparams to follow, but medium because there are a bunch of moving parts that will need to be done:
add the validators for the rcaparms
add the values to the default matplotlibrc
add tests that changing the rcparams works and overridding it at call time works
add a "whats new"
maybe add an example or extend an existing example to make use of the new rcparams
@jklymak could you comment on why this would conflict with constrained layout? If we can already control these things through kwargs I would not expect making them controllable via rcparam to cause any (new) problems.
Note that docstrings are autogenerated via a common template for suptitle, supxlabel, supylabel and parameter defaults are substituted. This would need adption to include the rcParams for suptitle, which will be a bit fiddly.
Naming: I propose to use figure.title_horizontalalignment instead of figure.titleha. We should not be using abbreviations for the rcParams. While most of the names do not include underscores figure.titlehorizontalalignment seems too unreadable, and we have precedence for underscores, e.g. in legend.title_fontsize.
If the scope is as explained by @tacaswell 's comment, I would like to take this up. Might need a little help to make sure what'll be the correct starting point though. Not sure about the constrained_layout issue though?
As @oscargus mentioned, doing it for supx/ylabel makes it much easier to implement and that should also take care of the docstrings if I understand right? Since then we won't have to have different things for suptitle and supx/ylabel. So should I work on having it for all three or do we want to do it just for the title?
Sorry there is no issue with constrained layout. The issue is with aligning the x/ylabels and the title. We need a sentinel for "default location" which has historically been the default location. Then we allow ourselves to move the label to avoid any ticks or other inner decorations. For xlabel and title this only affects the y and for glabelle this only affects the x.
If the user sets the y value for the title to something other than the default, we respect that value and don't try to adjust.
If we make these things have rcparams do we respect the values passed or do we assume the user still wants the automatic shifting of the title if the y value is equal to their rcparam default?
Thanks, @jklymak ! I think I understand what you mean. But in that case, if the user is asking to use a constrained layout, doesn't that by itself imply that they're fine with the locations changing to achieve the constrained layout? In my mind, this is similar to layout="constrained" having the highest priority, followed by the value passed as an argument, with rcparam value being the least priority but default.
Ohh my bad. Sorry. In that case, I think the set rcparam value comes with the understanding that automatic placement still happens to make the figure clear. I don't think that would be something undesirable by the user.
I was taking a look at this PR. Is there any other example I can refer to?
#22566 added another set of rcparams for suptitle/supxlabel/supylabel so it may be worth checking, especially how to get the docs to generate correctly. Which is also why I claimed that it may be easier to add something similar to supxlabel and supylabel as well, although not sure that one would like to have the same alignment for both (figure.xlabel_horizontalalignment etc ?).
@tacaswell i can take this one. i’ll add rcParams entries for figure.titlelocation (and optionally ha/va) following the same pattern as axes.titlelocation, then update suptitle() to use them. i’ll include tests and docs.
My thinking is that values from rcParams should be treated the same as the current hardcoded defaults — i.e. the automatic position adjustment should still apply. The intent when a user sets figure.title_y in their matplotlibrc is "I want the default position slightly different," not "please pin the title to this exact y coordinate forever."
This keeps the behavior consistent with axes.titlelocation: changing that rcParam shifts the horizontal anchor but constrained_layout still adjusts the vertical position to avoid ticks.
If a user genuinely wants to suppress auto-shifting, they can pass y=... explicitly to fig.suptitle(), which already triggers the "user-specified, do not adjust" path today.
Activity
oscargus commentedon Oct 15, 2022
Do you think the same should be available for
supx/ylabel? (From an implementation perspective it may actually be simpler...)jklymak commentedon Oct 15, 2022
Anyone who wants to do this will want to make sure there is still a way for constrained_layout to work.
tacaswell commentedon Oct 16, 2022
I think this is a good first issue because there is limited API choices to be made and there are good examples of merged PRs adding rcparams to follow, but medium because there are a bunch of moving parts that will need to be done:
@jklymak could you comment on why this would conflict with constrained layout? If we can already control these things through kwargs I would not expect making them controllable via rcparam to cause any (new) problems.
timhoffm commentedon Oct 16, 2022
Note that docstrings are autogenerated via a common template for
suptitle,supxlabel,supylabeland parameter defaults are substituted. This would need adption to include the rcParams for suptitle, which will be a bit fiddly.Naming: I propose to use
figure.title_horizontalalignmentinstead offigure.titleha. We should not be using abbreviations for the rcParams. While most of the names do not include underscoresfigure.titlehorizontalalignmentseems too unreadable, and we have precedence for underscores, e.g. inlegend.title_fontsize.chahak13 commentedon Oct 31, 2022
If the scope is as explained by @tacaswell 's comment, I would like to take this up. Might need a little help to make sure what'll be the correct starting point though. Not sure about the constrained_layout issue though?
tacaswell commentedon Oct 31, 2022
Tim's comment also needs to be fully addressed.
chahak13 commentedon Oct 31, 2022
Yep, that too. I know a little less about it but should be able to pick it up! :)
chahak13 commentedon Nov 1, 2022
#24031
I was taking a look at this PR. Is there any other example I can refer to?
chahak13 commentedon Nov 1, 2022
As @oscargus mentioned, doing it for
supx/ylabelmakes it much easier to implement and that should also take care of the docstrings if I understand right? Since then we won't have to have different things forsuptitleandsupx/ylabel. So should I work on having it for all three or do we want to do it just for the title?jklymak commentedon Nov 3, 2022
Sorry there is no issue with constrained layout. The issue is with aligning the x/ylabels and the title. We need a sentinel for "default location" which has historically been the default location. Then we allow ourselves to move the label to avoid any ticks or other inner decorations. For xlabel and title this only affects the y and for glabelle this only affects the x.
If the user sets the y value for the title to something other than the default, we respect that value and don't try to adjust.
If we make these things have rcparams do we respect the values passed or do we assume the user still wants the automatic shifting of the title if the y value is equal to their rcparam default?
chahak13 commentedon Nov 3, 2022
Thanks, @jklymak ! I think I understand what you mean. But in that case, if the user is asking to use a constrained layout, doesn't that by itself imply that they're fine with the locations changing to achieve the constrained layout? In my mind, this is similar tolayout="constrained"having the highest priority, followed by the value passed as an argument, with rcparam value being the least priority but default.jklymak commentedon Nov 3, 2022
My comment has nothing to do with constrained_layout, but rather to do with the automatic placement of the labels.
chahak13 commentedon Nov 3, 2022
Ohh my bad. Sorry. In that case, I think the set rcparam value comes with the understanding that automatic placement still happens to make the figure clear. I don't think that would be something undesirable by the user.
oscargus commentedon Nov 3, 2022
#22566 added another set of rcparams for suptitle/supxlabel/supylabel so it may be worth checking, especially how to get the docs to generate correctly. Which is also why I claimed that it may be easier to add something similar to supxlabel and supylabel as well, although not sure that one would like to have the same alignment for both (
figure.xlabel_horizontalalignmentetc ?).Myhfuz88Sk commentedon Jul 5, 2025
Is it issue still open can i work on this
yoadjei commentedon Mar 4, 2026
@tacaswell i can take this one. i’ll add
rcParamsentries forfigure.titlelocation(and optionallyha/va) following the same pattern asaxes.titlelocation, then updatesuptitle()to use them. i’ll include tests and docs.Add figure.titlex/y/ha/va rcParams for suptitle position and alignment
RishabhXYZA commentedon Mar 26, 2026
Hi I'm interested in working on this issue,
My Plan is to add rcParams support for "figure.suptitle()" kwargs,foloowing the same pattern used by similar text properties in Matplotlib.
Happy to discuss the approach before submitting a PR.
ENH: Add color rcParam support for suptitle
fix: rename rcParams per maintainer feedback
szzhoujiarui-sketch commentedon Jun 17, 2026
Thanks for raising this, Jody.
My thinking is that values from rcParams should be treated the same as the current hardcoded defaults — i.e. the automatic position adjustment should still apply. The intent when a user sets
figure.title_yin their matplotlibrc is "I want the default position slightly different," not "please pin the title to this exact y coordinate forever."This keeps the behavior consistent with
axes.titlelocation: changing that rcParam shifts the horizontal anchor butconstrained_layoutstill adjusts the vertical position to avoid ticks.If a user genuinely wants to suppress auto-shifting, they can pass
y=...explicitly tofig.suptitle(), which already triggers the "user-specified, do not adjust" path today.timhoffm commentedon Jun 26, 2026
I remove the "Good first issue" tag. Now that we have the 9th PR that does not cleanly solve this, I claim it's obviously not simple to solve.