diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 86a9fdd1387e..09a2a385b4e8 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -331,8 +331,9 @@ def _suplabels(self, t, info, **kwargs): @_docstring.copy(_suplabels) def suptitle(self, t, **kwargs): # docstring from _suplabels... - info = {'name': '_suptitle', 'x0': 0.5, 'y0': 0.98, - 'ha': 'center', 'va': 'top', 'rotation': 0, + info = {'name': '_suptitle', 'x0': 'figure.title_x', + 'y0': 'figure.title_y', 'ha': 'figure.title_ha', + 'va': 'figure.title_va', 'rotation': 0, 'size': 'figure.titlesize', 'weight': 'figure.titleweight'} return self._suplabels(t, info, **kwargs) diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc index 9bd8a622092e..bdef8bd468dd 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -557,6 +557,10 @@ ## * FIGURE * ## *************************************************************************** ## See https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure +#figure.title_x: 0.5 +#figure.title_y: 0.98 +#figure.title_ha: center +#figure.title_va: center #figure.titlesize: large # size of the figure title (``Figure.suptitle()``) #figure.titleweight: normal # weight of the figure title #figure.labelsize: large # size of the figure label (``Figure.sup[x|y]label()``) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 38d4606024d3..550ee292fdad 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1218,6 +1218,10 @@ def _convert_validator_spec(key, conv): # figure title "figure.titlesize": validate_fontsize, "figure.titleweight": validate_fontweight, + "figure.title_x": validate_float, + "figure.title_y": validate_float, + "figure.title_ha": ["center", "left", "right"], + "figure.title_va": ["top", "center", "bottom", "baseline"], # figure labels "figure.labelsize": validate_fontsize, diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 9d6e78da2cbc..586e1c49c057 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -446,3 +446,31 @@ def test_polar_log(): n = 100 ax.plot(np.linspace(0, 2 * np.pi, n), np.logspace(0, 2, n)) + + +def test_polar_rc_params(): + fig = plt.figure(figsize=(9, 3)) + ax = fig.add_subplot(polar=True) + + ax.set_rscale('log') + ax.set_rlim(1, 1000) + + n = 100 + ax.plot(np.linspace(0, 2 * np.pi, n), np.logspace(0, 2, n)) + + plt.subplot(132) + plt.scatter(["1", "2"], [3, 4]) + + # Control + fig.suptitle("First Title", x=0.1, y=0.2, ha="right", va="bottom", + weight='light', size=20) + + # Test suptitle + with mpl.rc_context({'figure.title_x': 0.1, + 'figure.title_y': 0.2, + 'figure.title_ha': "right", + 'figure.title_va': "bottom", + 'figure.titleweight': 'light', + 'figure.titlesize': 20 + }): + fig.suptitle("First Title")