8000 New rcParams to set pyplot.suptitle() defaults · matplotlib/matplotlib@760a8fd · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 760a8fd

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 0d4c559 commit 760a8fd

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
@@ -679,6 +679,10 @@ def __call__(self, s):
679679

680680

681681
## figure props
682+
# figure title
683+
'figure.titlesize': ['xx-large', validate_fontsize],
684+
'figure.titleweight': ['normal', six.text_type],
685+
682686
# figure size in inches: width by height
683687
'figure.figsize': [[8.0, 6.0], validate_nseq_float(2)],
684688
'figure.dpi': [80, validate_float], # DPI

matplotlibrc.template

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

321321
### FIGURE
322322
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure
323+
#figure.titlesize : xx-large # size of the figure title
324+
#figure.titleweight : normal # weight of the figure title
323325
#figure.figsize : 8, 6 # figure size in inches
324326
#figure.dpi : 80 # figure dots per inch
325327
#figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray

0 commit comments

Comments
 (0)
0