From 1cd461def4149cc6dfff80350fc06b8805208292 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 4 Dec 2023 01:00:57 -0500 Subject: [PATCH 1/7] Sending rcParams Pull Request with this commit --- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/mpl-data/matplotlibrc | 4 ++++ lib/matplotlib/rcsetup.py | 4 ++++ lib/matplotlib/tests/test_polar.py | 26 ++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 86a9fdd1387e..d49c2e579d11 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -331,8 +331,8 @@ 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_locx', 'y0': 'figure.title_locy', + '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..cce6e4150168 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.titleloc_x: 0.5 +#figure.titleloc_y: 0.98 +#figure.titleha: center +#figure.titleva: 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..8b37d2ebac40 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_locx": validate_float, + "figure.title_locy": 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..0d46a4fae62e 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -446,3 +446,29 @@ 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") + + # Test suptitle + with mpl.rc_context({'figure.title_x': 0.1, + 'figure.title_y': 0.2, + 'figure.title_ha': "right", + 'figure.title_va': "bottom", + }) + + fig.suptitle("First Title") From f42a1a88835f7a5041bdd61a117e0e9fb17267ed Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 4 Dec 2023 01:22:09 -0500 Subject: [PATCH 2/7] Attempting to fix linting --- lib/matplotlib/figure.py | 5 +++-- lib/matplotlib/tests/test_polar.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index d49c2e579d11..bc813327a5aa 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': 'figure.title_locx', 'y0': 'figure.title_locy', - 'ha': 'figure.title_ha', 'va': 'figure.title_va', 'rotation': 0, + info = {'name': '_suptitle', 'x0': 'figure.title_locx', + 'y0': 'figure.title_locy', '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/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 0d46a4fae62e..3ca11cf160ad 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -460,7 +460,7 @@ def test_polar_rc_params(): plt.subplot(132) plt.scatter(["1", "2"], [3,4]) - + # Control fig.suptitle("First Title", x=0.1, y=0.2, ha="right", va="bottom") @@ -470,5 +470,5 @@ def test_polar_rc_params(): 'figure.title_ha': "right", 'figure.title_va': "bottom", }) - - fig.suptitle("First Title") + + fig.suptitle("First Title") \ No newline at end of file From e5621457016c64d11402038040ff0998d1a6e6a4 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 4 Dec 2023 01:31:11 -0500 Subject: [PATCH 3/7] Fixing most lint issues --- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/tests/test_polar.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index bc813327a5aa..00602d7ae56f 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -331,8 +331,8 @@ def _suplabels(self, t, info, **kwargs): @_docstring.copy(_suplabels) def suptitle(self, t, **kwargs): # docstring from _suplabels... - info = {'name': '_suptitle', 'x0': 'figure.title_locx', - 'y0': 'figure.title_locy', 'ha': 'figure.title_ha', + info = {'name': '_suptitle', 'x0': 'figure.title_locx', + 'y0': 'figure.title_locy', '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/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 3ca11cf160ad..c11cd331b97c 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -449,7 +449,7 @@ def test_polar_log(): def test_polar_rc_params(): - fig = plt.figure(figsize=(9,3)) + fig = plt.figure(figsize=(9, 3)) ax = fig.add_subplot(polar=True) ax.set_rscale('log') @@ -469,6 +469,6 @@ def test_polar_rc_params(): 'figure.title_y': 0.2, 'figure.title_ha': "right", 'figure.title_va': "bottom", - }) + }) - fig.suptitle("First Title") \ No newline at end of file + fig.suptitle("First Title") From 5c43bc68274db68bb3924b2d96c81c8ec7051187 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 4 Dec 2023 01:33:56 -0500 Subject: [PATCH 4/7] Fixed lint on line 462 --- lib/matplotlib/tests/test_polar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index c11cd331b97c..5aec7b28d827 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -459,7 +459,7 @@ def test_polar_rc_params(): ax.plot(np.linspace(0, 2 * np.pi, n), np.logspace(0, 2, n)) plt.subplot(132) - plt.scatter(["1", "2"], [3,4]) + plt.scatter(["1", "2"], [3, 4]) # Control fig.suptitle("First Title", x=0.1, y=0.2, ha="right", va="bottom") From 017f0c2a96ba540f99813f6e813997031345b6a6 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 4 Dec 2023 16:49:56 -0500 Subject: [PATCH 5/7] Added other parameters for default testing --- lib/matplotlib/tests/test_polar.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 5aec7b28d827..586e1c49c057 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -462,13 +462,15 @@ def test_polar_rc_params(): plt.scatter(["1", "2"], [3, 4]) # Control - fig.suptitle("First Title", x=0.1, y=0.2, ha="right", va="bottom") + 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", - }) - - fig.suptitle("First Title") + 'figure.titleweight': 'light', + 'figure.titlesize': 20 + }): + fig.suptitle("First Title") From 3f04ebb6b5de78a47f76acc0bf642376c020a4ec Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 6 Dec 2023 14:53:09 -0500 Subject: [PATCH 6/7] Standardized naming to title_x and title_y --- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/mpl-data/matplotlibrc | 4 ++-- lib/matplotlib/rcsetup.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 00602d7ae56f..09a2a385b4e8 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -331,8 +331,8 @@ def _suplabels(self, t, info, **kwargs): @_docstring.copy(_suplabels) def suptitle(self, t, **kwargs): # docstring from _suplabels... - info = {'name': '_suptitle', 'x0': 'figure.title_locx', - 'y0': 'figure.title_locy', 'ha': 'figure.title_ha', + 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 cce6e4150168..b79f9a833f6f 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -557,8 +557,8 @@ ## * FIGURE * ## *************************************************************************** ## See https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure -#figure.titleloc_x: 0.5 -#figure.titleloc_y: 0.98 +#figure.title_x: 0.5 +#figure.title_y: 0.98 #figure.titleha: center #figure.titleva: center #figure.titlesize: large # size of the figure title (``Figure.suptitle()``) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 8b37d2ebac40..550ee292fdad 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1218,8 +1218,8 @@ def _convert_validator_spec(key, conv): # figure title "figure.titlesize": validate_fontsize, "figure.titleweight": validate_fontweight, - "figure.title_locx": validate_float, - "figure.title_locy": validate_float, + "figure.title_x": validate_float, + "figure.title_y": validate_float, "figure.title_ha": ["center", "left", "right"], "figure.title_va": ["top", "center", "bottom", "baseline"], From 1ae3050f5a7cdbaa0d46efd5397c5a5f19abdc04 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 6 Dec 2023 17:08:19 -0500 Subject: [PATCH 7/7] Standardized naming to title_ha and title_va --- lib/matplotlib/mpl-data/matplotlibrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc index b79f9a833f6f..bdef8bd468dd 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -557,10 +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.titleha: center -#figure.titleva: center +#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()``)