From 0153828e9ab9bc19cac602d646658aed113d488b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Wessl=C3=A9n?= Date: Tue, 2 Mar 2021 11:38:10 +0100 Subject: [PATCH 1/2] Add test testing #19296 Co-authored-by: Agriad Co-authored-by: davek10 <94davek@gmail.com> Co-authored-by: tjr16 --- lib/matplotlib/tests/test_transforms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py index ad572fe5287a..75702a608219 100644 --- a/lib/matplotlib/tests/test_transforms.py +++ b/lib/matplotlib/tests/test_transforms.py @@ -460,6 +460,12 @@ def assert_bbox_eq(bbox1, bbox2): assert_array_equal(bbox1.bounds, bbox2.bounds) +def test_bbox_frozen_copies_minpos(): + bbox = mtransforms.Bbox.from_extents(0.0, 0.0, 1.0, 1.0, minpos=1.0) + frozen = bbox.frozen() + assert_array_equal(frozen.minpos, bbox.minpos) + + def test_bbox_intersection(): bbox_from_ext = mtransforms.Bbox.from_extents inter = mtransforms.Bbox.intersection From 90fcad640b2edc4e14d4d77b9715c921a80840ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Wessl=C3=A9n?= Date: Tue, 2 Mar 2021 11:40:55 +0100 Subject: [PATCH 2/2] Add overriding frozen function to Bbox This function copies minpos when frozen is called. This commit resolves #19296. Co-authored-by: Agriad Co-authored-by: davek10 <94davek@gmail.com> Co-authored-by: tjr16 --- lib/matplotlib/transforms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 9a50e4bf0048..e2051a41346b 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -807,6 +807,12 @@ def invalidate(self): self._check(self._points) super().invalidate() + def frozen(self): + # docstring inherited + frozen_bbox = super().frozen() + frozen_bbox._minpos = self.minpos.copy() + return frozen_bbox + @staticmethod def unit(): """Create a new unit `Bbox` from (0, 0) to (1, 1)."""