From 8f23c9571d92562712d680b305271521253db787 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 28 Jul 2021 15:21:34 -0700 Subject: [PATCH 1/2] FIX: fix autopos and constrainedlayout if parallel co-ord --- lib/matplotlib/figure.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index e47d7c083625..404179341264 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -370,7 +370,10 @@ def _suplabels(self, t, info, **kwargs): x = kwargs.pop('x', None) y = kwargs.pop('y', None) - autopos = x is None and y is None + if info['name'] in ['_supxlabel', '_suptitle']: + autopos = y is None + elif info['name'] == '_supylabel': + autopos = x is None if x is None: x = info['x0'] if y is None: From e022c04773b784d46a926815e41855b1feaa35ad Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 28 Jul 2021 15:32:47 -0700 Subject: [PATCH 2/2] TST: add test that CL works after manually setting the parallel position --- .../tests/test_constrainedlayout.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/matplotlib/tests/test_constrainedlayout.py b/lib/matplotlib/tests/test_constrainedlayout.py index 0dbf128fc672..007fac6ec1f9 100644 --- a/lib/matplotlib/tests/test_constrainedlayout.py +++ b/lib/matplotlib/tests/test_constrainedlayout.py @@ -537,3 +537,26 @@ def test_align_labels(): after_align[1].x0, rtol=0, atol=1e-05) # ensure labels do not go off the edge assert after_align[0].x0 >= 1 + + +def test_suplabels(): + fig, ax = plt.subplots(constrained_layout=True) + fig.draw_no_output() + pos0 = ax.get_tightbbox(fig.canvas.get_renderer()) + fig.supxlabel('Boo') + fig.supylabel('Booy') + fig.draw_no_output() + pos = ax.get_tightbbox(fig.canvas.get_renderer()) + assert pos.y0 > pos0.y0 + 10.0 + assert pos.x0 > pos0.x0 + 10.0 + + fig, ax = plt.subplots(constrained_layout=True) + fig.draw_no_output() + pos0 = ax.get_tightbbox(fig.canvas.get_renderer()) + # check that specifying x (y) doesn't ruin the layout + fig.supxlabel('Boo', x=0.5) + fig.supylabel('Boo', y=0.5) + fig.draw_no_output() + pos = ax.get_tightbbox(fig.canvas.get_renderer()) + assert pos.y0 > pos0.y0 + 10.0 + assert pos.x0 > pos0.x0 + 10.0 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy