Skip to content

Commit dd2a31d

Browse files
committed
Merge pull request matplotlib#3083 from wavexx/suptitle
ENH : New rcParams to set pyplot.suptitle() defaults
2 parents 8e7d6c3 + 9cef470 commit dd2a31d

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

doc/users/whats_new/rcparams.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ Added "legend.framealpha" key to rcParams
44
Added a key and the corresponding logic to control the default transparency of
55
legend frames. This feature was written into the docstring of axes.legend(),
66
but not yet implemented.
7+
8+
9+
Added "figure.titlesize" and "figure.titleweight" keys to rcParams
10+
``````````````````````````````````````````````````````````````````
11+
12+
Two new keys were added to rcParams to control the default font size and weight
13+
used by the figure title (as emitted by ``pyplot.suptitle()``).

lib/matplotlib/figure.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,17 @@ def suptitle(self, t, **kwargs):
518518
"""
519519
x = kwargs.pop('x', 0.5)
520520
y = kwargs.pop('y', 0.98)
521+
521522
if ('horizontalalignment' not in kwargs) and ('ha' not in kwargs):
522523
kwargs['horizontalalignment'] = 'center'
523-
524524
if ('verticalalignment' not in kwargs) and ('va' not in kwargs):
525525
kwargs['verticalalignment'] = 'top'
526526

527+
if 'fontsize' not in kwargs:
528+
kwargs['fontsize'] = rcParams['figure.titlesize']
529+
if 'fontweight' not in kwargs:
530+
kwargs['fontweight'] = rcParams['figure.titleweight']
531+
527532
sup = self.text(x, y, t, **kwargs)
528533
if self._suptitle is not None:
529534
self._suptitle.set_text(t)

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ def __call__(self, s):
692692

693693

694694
## figure props
695+
# figure title
696+
'figure.titlesize': ['medium', validate_fontsize],
697+
'figure.titleweight': ['normal', six.text_type],
698+
695699
# figure size in inches: width by height
696700
'figure.figsize': [[8.0, 6.0], validate_nseq_float(2)],
697701
'figure.dpi': [80, validate_float], # DPI

matplotlibrc.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ backend : %(backend)s
326326

327327
### FIGURE
328328
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure
329+
#figure.titlesize : medium # size of the figure title
330+
#figure.titleweight : normal # weight of the figure title
329331
#figure.figsize : 8, 6 # figure size in inches
330332
#figure.dpi : 80 # figure dots per inch
331333
#figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray

0 commit comments

Comments
 (0)