Skip to content

Commit c8698b9

Browse files
committed
New rcParams to set pyplot.suptitle() defaults
Two new rcParams are introduced: - figure.titlesize (xx-large) - figure.titleweight (normal) Allow to set the pyplot.suptitle() default font size and weight.
1 parent ed95382 commit c8698b9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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)