diff --git a/doc/devel/testing.rst b/doc/devel/testing.rst index 72f787eca746..97e907a0fbca 100644 --- a/doc/devel/testing.rst +++ b/doc/devel/testing.rst @@ -161,9 +161,10 @@ the tests, they should now pass. It is preferred that new tests use ``style='mpl20'`` as this leads to smaller figures and reflects the newer look of default Matplotlib plots. Also, if the -texts (labels, tick labels, etc) are not really part of what is tested, use -``remove_text=True`` as this will lead to smaller figures and reduce possible -issues with font mismatch on different platforms. +texts (labels, tick labels, etc) are not really part of what is tested, use the +``remove_text=True`` argument or add the ``text_placeholders`` fixture as this +will lead to smaller figures and reduce possible issues with font mismatch on +different platforms. Compare two methods of creating an image diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py index 3f96de611195..2961e7f02f3f 100644 --- a/lib/matplotlib/testing/conftest.py +++ b/lib/matplotlib/testing/conftest.py @@ -125,3 +125,54 @@ def test_imshow_xarray(xr): xr = pytest.importorskip('xarray') return xr + + +@pytest.fixture +def text_placeholders(monkeypatch): + """ + Replace texts with placeholder rectangles. + + The rectangle size only depends on the font size and the number of characters. It is + thus insensitive to font properties and rendering details. This should be used for + tests that depend on text geometries but not the actual text rendering, e.g. layout + tests. + """ + from matplotlib.patches import Rectangle + + def patched_get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi): + """ + Replace ``_get_text_metrics_with_cache`` with fixed results. + + The usual ``renderer.get_text_width_height_descent`` would depend on font + metrics; instead the fixed results are based on font size and the length of the + string only. + """ + # While get_window_extent returns pixels and font size is in points, font size + # includes ascenders and descenders. Leaving out this factor and setting + # descent=0 ends up with a box that is relatively close to DejaVu Sans. + height = fontprop.get_size() + width = len(text) * height / 1.618 # Golden ratio for character size. + descent = 0 + return width, height, descent + + def patched_text_draw(self, renderer): + """ + Replace ``Text.draw`` with a fixed bounding box Rectangle. + + The bounding box corresponds to ``Text.get_window_extent``, which ultimately + depends on the above patched ``_get_text_metrics_with_cache``. + """ + if renderer is not None: + self._renderer = renderer + if not self.get_visible(): + return + if self.get_text() == '': + return + bbox = self.get_window_extent() + rect = Rectangle(bbox.p0, bbox.width, bbox.height, + facecolor=self.get_color(), edgecolor='none') + rect.draw(renderer) + + monkeypatch.setattr('matplotlib.text._get_text_metrics_with_cache', + patched_get_text_metrics_with_cache) + monkeypatch.setattr('matplotlib.text.Text.draw', patched_text_draw) diff --git a/lib/matplotlib/testing/conftest.pyi b/lib/matplotlib/testing/conftest.pyi index 2af0eb93cc8a..f5d90bc88f73 100644 --- a/lib/matplotlib/testing/conftest.pyi +++ b/lib/matplotlib/testing/conftest.pyi @@ -10,3 +10,5 @@ def mpl_test_settings(request: pytest.FixtureRequest) -> None: ... def pd() -> ModuleType: ... @pytest.fixture def xr() -> ModuleType: ... +@pytest.fixture +def text_placeholders(monkeypatch: pytest.MonkeyPatch) -> None: ... diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout1.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout1.png index 25eade2b6297..bfbbfd6f7eeb 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout1.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout1.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout10.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout10.png index 1d23c1db38de..8dc29f4cbc36 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout10.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout10.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11.png index f337d370dc33..e850318d8d8f 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11rat.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11rat.png index 534903300f7a..4d150d3cf06f 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11rat.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout11rat.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout12.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout12.png index 07e35e9d800a..6f5625ae2605 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout12.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout12.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout13.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout13.png index 4233f58a8ce4..9fa680160c3d 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout13.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout13.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout14.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout14.png index cfe9dca14c88..3a908eb8bf58 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout14.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout14.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout15.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout15.png index 6790ac835838..02f7f29fe7de 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout15.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout15.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout16.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout16.png index 841cf77b7e08..f2a8172ffb7d 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout16.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout16.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout17.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout17.png index 8af582f00926..7ac78631798e 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout17.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout17.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout2.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout2.png index 575cd9a45b7e..1d8e03c3cd54 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout2.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout2.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout3.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout3.png index ae6420dd04e9..77e90bc09062 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout3.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout3.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout4.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout4.png index ef6d9e417f91..42b87f03f1d0 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout4.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout4.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout5.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout5.png index 89e71b765154..297391b17837 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout5.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout5.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout6.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout6.png index 6ba96e41a34d..a50f2f1dabcc 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout6.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout6.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout8.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout8.png index a239947ca46c..99ba9f294a7a 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout8.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout8.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout9.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout9.png index 2ac44b8a18ac..a1e9da294e64 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout9.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/constrained_layout9.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapH.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapH.png index d91bcdf22b7a..b1081ba44d0a 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapH.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapH.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapV.png b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapV.png index 1768fc2fdc35..b4a1133e5eda 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapV.png and b/lib/matplotlib/tests/baseline_images/test_constrainedlayout/test_colorbars_no_overlapV.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_table/table_cell_manipulation.png b/lib/matplotlib/tests/baseline_images/test_table/table_cell_manipulation.png index 778e57802982..ee2558b3ebc6 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_table/table_cell_manipulation.png and b/lib/matplotlib/tests/baseline_images/test_table/table_cell_manipulation.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.pdf index c414e59fe1b8..e1901b3b3a7a 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.png index 00c8afb79604..461e51941979 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.svg index 4bc99a39910f..3664df99d1a4 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout1.svg @@ -1,505 +1,200 @@ - - + + + + + + 2025-04-09T03:27:51.168685 + image/svg+xml + + + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ + + + + + - + - +" style="fill: #ffffff"/> - - - - - - - - - - - - - - - - +" style="fill: #ffffff"/> - + - + - + - - - - - - - - - - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - - + - - - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - + - - - - - - +"/> - - - - + - - - - - - - - - - +"/> - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - +"/> - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.pdf index e26705d0038a..a70180a9192c 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.png index 5197602445ae..b690212612b8 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.svg index 2075eca4868f..2617cd5c2495 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout2.svg @@ -1,16 +1,16 @@ - + - 2024-07-07T03:48:17.981141 + 2025-04-09T03:27:52.212752 image/svg+xml - Matplotlib v0.1.0.dev50519+g9c53d4f.d20240707, https://matplotlib.org/ + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ @@ -21,1098 +21,648 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - + - - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - - + - - - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - + - - - - - +"/> - - - - - + - - - - - - - - - +"/> - - - - - - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - - - - - - - - - + - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.pdf index 5d386cc05fe3..c5307c13d72f 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.png index d6428c63e39f..fe5d3a483670 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.svg index d7d66b644771..a32d43a6f703 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout3.svg @@ -1,16 +1,16 @@ - + - 2024-07-07T03:48:18.249876 + 2025-04-09T03:27:51.909780 image/svg+xml - Matplotlib v0.1.0.dev50519+g9c53d4f.d20240707, https://matplotlib.org/ + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ @@ -21,902 +21,492 @@ - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - - - - - - + - - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - - - + - - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - + - - - - - +"/> - - - - - + - - - - - - - - - +"/> - - - - - - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.pdf index 1eaa92bd153e..74a45957ea72 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.png index afcf843968d9..6a0088d6e18b 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.svg index 27f30e5a363b..28b001a01475 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout4.svg @@ -1,16 +1,16 @@ - + - 2024-07-07T03:48:18.594236 + 2025-04-09T03:27:51.858300 image/svg+xml - Matplotlib v0.1.0.dev50519+g9c53d4f.d20240707, https://matplotlib.org/ + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ @@ -21,1098 +21,648 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - + - - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - + - + - - - - - + - - - - - +"/> - - - - - - - + - - - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - + - - - - - +"/> - - - - - + - - - - - - - - - +"/> - - - - - - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - - - - - - - - - + - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.pdf index 7132b252484f..e034e898d257 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.png index b28d5098b835..5c176e83934c 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.svg index 0443685b49b0..2b3aba91681b 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout5.svg @@ -1,16 +1,16 @@ - + - 2023-04-16T19:42:04.013561 + 2025-04-09T03:27:51.453043 image/svg+xml - Matplotlib v3.8.0.dev855+gc9636b5044.d20230417, https://matplotlib.org/ + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ @@ -21,398 +21,215 @@ - - - + - - - - - - - - - - - - +iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAz0lEQVR4nFWMu00EURAEq3vm3T4HBwxOCOOEyIEELgRCJwACwOQn7e4bjF2dDmPUVa3W6KzXwoFaogiUCRGQiTJ2DjKfTlRuUjaVpkJUeD9RafL3dEelKIsKGFdcFiOgDPn5eLhIXVJXvA+/HrQV/4b1r8NF/hwH5YLYBqggCgyKgVwoiozjN3YRMbCL9CBjEB4be9BiJZ/vP0gPDl4u2TSYYtl5ZfJCvty+0z0zeaZppWumaaF75rB710yeb97o2r50rXQVDegyTWZSoyn4A2BiWT69Db/oAAAAAElFTkSuQmCC" id="imagef5c2a23f35" transform="matrix(30.98 0 0 30.98 75.5 10.8)" style="image-rendering:crisp-edges;image-rendering:pixelated" width="10" height="10"/> - - - - - - - - - + - + - - - - - + - - - +"/> - - - - - - + - + - - - - - + - - - +"/> - - - - - - + - + - - - - - + - - - +"/> - - - - - - + - + - - - - - + - - - +"/> - - - - - - + - + - - - - - + - - - +"/> - - - - - - - - - + - + - + - - - - - + + - - - - - - + - + - - - - - + + - - - - - - + - + - - - - - + + - - - - - - + - + - - - - - + + - - - - - - + - + - - - - - + + + + + + + + + + + + + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.pdf index 32c853cad2da..67fc2d901fc9 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.png index cc203bf27864..faf641ba1ef3 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.svg index 51e048e2d92b..4b4aa7071372 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout6.svg @@ -1,1229 +1,784 @@ - - + + + + + + 2025-04-09T03:27:52.608841 + image/svg+xml + + + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ + + + + + - + - +" style="fill: #ffffff"/> - - - - - - - - - - - - - - - - +" style="fill: #ffffff"/> - + - + - + - - - - - - - - - - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - - - - + - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - - - - - - - - - - - - + - - - - - + - - - - - - - - - +"/> - - - - - - + - - - - - - - - +"/> - - - - + + - - + + - - + + - - + + - - + + - - + + + + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - +" style="fill: #ffffff"/> - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - + - + - - - - - - - - - - - - + + - - - - - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.pdf index b352ed0ebadd..03efb3454886 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.png index fa02aad51ce1..613e695f05a4 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.svg index c0aa6d0755a3..da698dd4ffb9 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout7.svg @@ -1,636 +1,208 @@ - - + + + + + + 2025-04-09T03:27:52.779409 + image/svg+xml + + + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ + + + + + - + - +" style="fill: #ffffff"/> - - - - - - - - - - - - - - - - +" style="fill: #ffffff"/> - + - + - + - - - - - - - - - - - - + - - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - - - - + - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - + - - - - - - +"/> - - - - + - - - - - - - - - - +"/> - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + + + + + + + + + + - + + + - - - - - - - - - - - - - - +"/> - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.pdf index 73a34ff7e3ac..01d5d00781b8 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.png index 13b7d894a265..e8aaa577dfcd 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.svg index 538d4441b2b8..f5acea9d851b 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout8.svg @@ -1,505 +1,200 @@ - - + + + + + + 2025-04-09T03:27:52.671035 + image/svg+xml + + + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ + + + + + - + - +" style="fill: #ffffff"/> - - - - - - - - - - - - - - - - +" style="fill: #ffffff"/> - + - + - + - - - - - - - - - - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - + - + - - - - + - - - - - - +"/> - - - - - - - + - - - - - - - - - - - - +"/> - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - + - - - - - - +"/> - - - - + - - - - - - - - - - +"/> - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - +"/> - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.pdf index c694c8431a21..d3a9b1286581 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.png index 2d63e6987a38..cd61aba5d9da 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.svg index ea6a6ea62151..0524e0b4a589 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout9.svg @@ -1,1017 +1,684 @@ - - + + + + + + 2025-04-09T03:27:52.897268 + image/svg+xml + + + Matplotlib v3.11.0.dev647+g7c466f9a72.d20250409, https://matplotlib.org/ + + + + + - + - +" style="fill: #ffffff"/> - - - - - - - - - - - - - +" style="fill: #ffffff"/> - - - - - - - - - + - + - - - - - - - - - - - + + - - - - - - + - + - - - - - - - - - - + + - - - - - - + - + - - - - - - - - - - + + - - - - - - + - + - - - - - - - - - - + + - - - - - - + - + - - - - - - - - - - + + - - - - - - + - + - - - - - - - - - - + + - - - - - - - - - + - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - + + - - + + - - + + - - + + - - + + + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + - - - - - - + - + - - - - - - - + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.pdf deleted file mode 100644 index 7300cf8ed51d..000000000000 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.pdf and /dev/null differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.png deleted file mode 100644 index a4d5e8f6f22a..000000000000 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.png and /dev/null differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.svg deleted file mode 100644 index e0587bbb902e..000000000000 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes1.svg +++ /dev/null @@ -1,1613 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.pdf deleted file mode 100644 index 85f669de45bc..000000000000 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.pdf and /dev/null differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.png deleted file mode 100644 index effa2c5d9f64..000000000000 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.png and /dev/null differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.svg deleted file mode 100644 index 88f7e0637e4e..000000000000 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/tight_layout_offsetboxes2.svg +++ /dev/null @@ -1,1469 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/matplotlib/tests/conftest.py b/lib/matplotlib/tests/conftest.py index 54a1bc6cae94..6afd566750e9 100644 --- a/lib/matplotlib/tests/conftest.py +++ b/lib/matplotlib/tests/conftest.py @@ -1,2 +1,2 @@ from matplotlib.testing.conftest import ( # noqa - mpl_test_settings, pytest_configure, pytest_unconfigure, pd, xr) + mpl_test_settings, pytest_configure, pytest_unconfigure, pd, text_placeholders, xr) diff --git a/lib/matplotlib/tests/test_constrainedlayout.py b/lib/matplotlib/tests/test_constrainedlayout.py index 77f9f34bc2d8..7c7dd43a3115 100644 --- a/lib/matplotlib/tests/test_constrainedlayout.py +++ b/lib/matplotlib/tests/test_constrainedlayout.py @@ -11,6 +11,11 @@ from matplotlib import gridspec, ticker +pytestmark = [ + pytest.mark.usefixtures('text_placeholders') +] + + def example_plot(ax, fontsize=12, nodec=False): ax.plot([1, 2]) ax.locator_params(nbins=3) @@ -36,7 +41,7 @@ def example_pcolor(ax, fontsize=12): return pcm -@image_comparison(['constrained_layout1.png']) +@image_comparison(['constrained_layout1.png'], style='mpl20') def test_constrained_layout1(): """Test constrained_layout for a single subplot""" fig = plt.figure(layout="constrained") @@ -44,7 +49,7 @@ def test_constrained_layout1(): example_plot(ax, fontsize=24) -@image_comparison(['constrained_layout2.png']) +@image_comparison(['constrained_layout2.png'], style='mpl20') def test_constrained_layout2(): """Test constrained_layout for 2x2 subplots""" fig, axs = plt.subplots(2, 2, layout="constrained") @@ -52,7 +57,7 @@ def test_constrained_layout2(): example_plot(ax, fontsize=24) -@image_comparison(['constrained_layout3.png']) +@image_comparison(['constrained_layout3.png'], style='mpl20') def test_constrained_layout3(): """Test constrained_layout for colorbars with subplots""" @@ -66,7 +71,7 @@ def test_constrained_layout3(): fig.colorbar(pcm, ax=ax, pad=pad) -@image_comparison(['constrained_layout4.png']) +@image_comparison(['constrained_layout4.png'], style='mpl20') def test_constrained_layout4(): """Test constrained_layout for a single colorbar with subplots""" @@ -76,7 +81,7 @@ def test_constrained_layout4(): fig.colorbar(pcm, ax=axs, pad=0.01, shrink=0.6) -@image_comparison(['constrained_layout5.png'], tol=0.002) +@image_comparison(['constrained_layout5.png'], style='mpl20') def test_constrained_layout5(): """ Test constrained_layout for a single colorbar with subplots, @@ -91,12 +96,9 @@ def test_constrained_layout5(): location='bottom') -@image_comparison(['constrained_layout6.png'], tol=0.002) +@image_comparison(['constrained_layout6.png'], style='mpl20') def test_constrained_layout6(): """Test constrained_layout for nested gridspecs""" - # Remove this line when this test image is regenerated. - plt.rcParams['pcolormesh.snap'] = False - fig = plt.figure(layout="constrained") gs = fig.add_gridspec(1, 2, figure=fig) gsl = gs[0].subgridspec(2, 2) @@ -154,7 +156,7 @@ def test_constrained_layout7(): fig.draw_without_rendering() -@image_comparison(['constrained_layout8.png']) +@image_comparison(['constrained_layout8.png'], style='mpl20') def test_constrained_layout8(): """Test for gridspecs that are not completely full""" @@ -182,7 +184,7 @@ def test_constrained_layout8(): fig.colorbar(pcm, ax=axs, pad=0.01, shrink=0.6) -@image_comparison(['constrained_layout9.png']) +@image_comparison(['constrained_layout9.png'], style='mpl20') def test_constrained_layout9(): """Test for handling suptitle and for sharex and sharey""" @@ -197,7 +199,7 @@ def test_constrained_layout9(): fig.suptitle('Test Suptitle', fontsize=28) -@image_comparison(['constrained_layout10.png'], +@image_comparison(['constrained_layout10.png'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.032) def test_constrained_layout10(): """Test for handling legend outside axis""" @@ -207,7 +209,7 @@ def test_constrained_layout10(): ax.legend(loc='center left', bbox_to_anchor=(0.8, 0.5)) -@image_comparison(['constrained_layout11.png']) +@image_comparison(['constrained_layout11.png'], style='mpl20') def test_constrained_layout11(): """Test for multiple nested gridspecs""" @@ -227,7 +229,7 @@ def test_constrained_layout11(): example_plot(ax, fontsize=9) -@image_comparison(['constrained_layout11rat.png']) +@image_comparison(['constrained_layout11rat.png'], style='mpl20') def test_constrained_layout11rat(): """Test for multiple nested gridspecs with width_ratios""" @@ -247,7 +249,7 @@ def test_constrained_layout11rat(): example_plot(ax, fontsize=9) -@image_comparison(['constrained_layout12.png']) +@image_comparison(['constrained_layout12.png'], style='mpl20') def test_constrained_layout12(): """Test that very unbalanced labeling still works.""" fig = plt.figure(layout="constrained", figsize=(6, 8)) @@ -269,7 +271,7 @@ def test_constrained_layout12(): ax.set_xlabel('x-label') -@image_comparison(['constrained_layout13.png'], tol=2.e-2) +@image_comparison(['constrained_layout13.png'], style='mpl20') def test_constrained_layout13(): """Test that padding works.""" fig, axs = plt.subplots(2, 2, layout="constrained") @@ -281,7 +283,7 @@ def test_constrained_layout13(): fig.get_layout_engine().set(w_pad=24./72., h_pad=24./72.) -@image_comparison(['constrained_layout14.png']) +@image_comparison(['constrained_layout14.png'], style='mpl20') def test_constrained_layout14(): """Test that padding works.""" fig, axs = plt.subplots(2, 2, layout="constrained") @@ -293,7 +295,7 @@ def test_constrained_layout14(): hspace=0.2, wspace=0.2) -@image_comparison(['constrained_layout15.png']) +@image_comparison(['constrained_layout15.png'], style='mpl20') def test_constrained_layout15(): """Test that rcparams work.""" mpl.rcParams['figure.constrained_layout.use'] = True @@ -302,7 +304,7 @@ def test_constrained_layout15(): example_plot(ax, fontsize=12) -@image_comparison(['constrained_layout16.png']) +@image_comparison(['constrained_layout16.png'], style='mpl20') def test_constrained_layout16(): """Test ax.set_position.""" fig, ax = plt.subplots(layout="constrained") @@ -310,7 +312,7 @@ def test_constrained_layout16(): ax2 = fig.add_axes([0.2, 0.2, 0.4, 0.4]) -@image_comparison(['constrained_layout17.png']) +@image_comparison(['constrained_layout17.png'], style='mpl20') def test_constrained_layout17(): """Test uneven gridspecs""" fig = plt.figure(layout="constrained") @@ -435,7 +437,7 @@ def test_hidden_axes(): extents1 = np.copy(axs[0, 0].get_position().extents) np.testing.assert_allclose( - extents1, [0.045552, 0.543288, 0.47819, 0.982638], rtol=1e-5) + extents1, [0.046918, 0.541204, 0.477409, 0.980555], rtol=1e-5) def test_colorbar_align(): @@ -641,7 +643,7 @@ def test_compressed1(): fig.draw_without_rendering() pos = axs[0, 0].get_position() - np.testing.assert_allclose(pos.x0, 0.2344, atol=1e-3) + np.testing.assert_allclose(pos.x0, 0.2381, atol=1e-2) pos = axs[0, 1].get_position() np.testing.assert_allclose(pos.x1, 0.7024, atol=1e-3) @@ -655,11 +657,11 @@ def test_compressed1(): fig.draw_without_rendering() pos = axs[0, 0].get_position() - np.testing.assert_allclose(pos.x0, 0.06195, atol=1e-3) - np.testing.assert_allclose(pos.y1, 0.8537, atol=1e-3) + np.testing.assert_allclose(pos.x0, 0.05653, atol=1e-3) + np.testing.assert_allclose(pos.y1, 0.8603, atol=1e-2) pos = axs[1, 2].get_position() - np.testing.assert_allclose(pos.x1, 0.8618, atol=1e-3) - np.testing.assert_allclose(pos.y0, 0.1934, atol=1e-3) + np.testing.assert_allclose(pos.x1, 0.8728, atol=1e-3) + np.testing.assert_allclose(pos.y0, 0.1808, atol=1e-2) def test_compressed_suptitle(): @@ -675,7 +677,7 @@ def test_compressed_suptitle(): title = fig.suptitle("Title") fig.draw_without_rendering() - assert title.get_position()[1] == pytest.approx(0.7457, abs=1e-3) + assert title.get_position()[1] == pytest.approx(0.7491, abs=1e-3) title = fig.suptitle("Title", y=0.98) fig.draw_without_rendering() diff --git a/lib/matplotlib/tests/test_table.py b/lib/matplotlib/tests/test_table.py index 783be25376be..29d1944323fc 100644 --- a/lib/matplotlib/tests/test_table.py +++ b/lib/matplotlib/tests/test_table.py @@ -87,13 +87,13 @@ def test_label_colours(): loc='best') -@image_comparison(['table_cell_manipulation.png'], remove_text=True) -def test_diff_cell_table(): +@image_comparison(['table_cell_manipulation.png'], style='mpl20') +def test_diff_cell_table(text_placeholders): cells = ('horizontal', 'vertical', 'open', 'closed', 'T', 'R', 'B', 'L') cellText = [['1'] * len(cells)] * 2 colWidths = [0.1] * len(cells) - _, axs = plt.subplots(nrows=len(cells), figsize=(4, len(cells)+1)) + _, axs = plt.subplots(nrows=len(cells), figsize=(4, len(cells)+1), layout='tight') for ax, cell in zip(axs, cells): ax.table( colWidths=colWidths, @@ -102,7 +102,6 @@ def test_diff_cell_table(): edges=cell, ) ax.axis('off') - plt.tight_layout() def test_customcell(): diff --git a/lib/matplotlib/tests/test_tightlayout.py b/lib/matplotlib/tests/test_tightlayout.py index 9c654f4d1f48..f6b6d8f644cc 100644 --- a/lib/matplotlib/tests/test_tightlayout.py +++ b/lib/matplotlib/tests/test_tightlayout.py @@ -11,6 +11,11 @@ from matplotlib.patches import Rectangle +pytestmark = [ + pytest.mark.usefixtures('text_placeholders') +] + + def example_plot(ax, fontsize=12): ax.plot([1, 2]) ax.locator_params(nbins=3) @@ -19,7 +24,7 @@ def example_plot(ax, fontsize=12): ax.set_title('Title', fontsize=fontsize) -@image_comparison(['tight_layout1'], tol=1.9) +@image_comparison(['tight_layout1'], style='mpl20') def test_tight_layout1(): """Test tight_layout for a single subplot.""" fig, ax = plt.subplots() @@ -27,7 +32,7 @@ def test_tight_layout1(): plt.tight_layout() -@image_comparison(['tight_layout2']) +@image_comparison(['tight_layout2'], style='mpl20') def test_tight_layout2(): """Test tight_layout for multiple subplots.""" fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2) @@ -38,7 +43,7 @@ def test_tight_layout2(): plt.tight_layout() -@image_comparison(['tight_layout3']) +@image_comparison(['tight_layout3'], style='mpl20') def test_tight_layout3(): """Test tight_layout for multiple subplots.""" ax1 = plt.subplot(221) @@ -50,8 +55,7 @@ def test_tight_layout3(): plt.tight_layout() -@image_comparison(['tight_layout4'], freetype_version=('2.5.5', '2.6.1'), - tol=0.015) +@image_comparison(['tight_layout4'], style='mpl20') def test_tight_layout4(): """Test tight_layout for subplot2grid.""" ax1 = plt.subplot2grid((3, 3), (0, 0)) @@ -65,7 +69,7 @@ def test_tight_layout4(): plt.tight_layout() -@image_comparison(['tight_layout5']) +@image_comparison(['tight_layout5'], style='mpl20') def test_tight_layout5(): """Test tight_layout for image.""" ax = plt.subplot() @@ -74,7 +78,7 @@ def test_tight_layout5(): plt.tight_layout() -@image_comparison(['tight_layout6']) +@image_comparison(['tight_layout6'], style='mpl20') def test_tight_layout6(): """Test tight_layout for gridspec.""" @@ -116,7 +120,7 @@ def test_tight_layout6(): h_pad=0.45) -@image_comparison(['tight_layout7'], tol=1.9) +@image_comparison(['tight_layout7'], style='mpl20') def test_tight_layout7(): # tight layout with left and right titles fontsize = 24 @@ -130,7 +134,7 @@ def test_tight_layout7(): plt.tight_layout() -@image_comparison(['tight_layout8'], tol=0.005) +@image_comparison(['tight_layout8'], style='mpl20', tol=0.005) def test_tight_layout8(): """Test automatic use of tight_layout.""" fig = plt.figure() @@ -140,7 +144,7 @@ def test_tight_layout8(): fig.draw_without_rendering() -@image_comparison(['tight_layout9']) +@image_comparison(['tight_layout9'], style='mpl20') def test_tight_layout9(): # Test tight_layout for non-visible subplots # GH 8244 @@ -174,10 +178,10 @@ def test_outward_ticks(): # These values were obtained after visual checking that they correspond # to a tight layouting that did take the ticks into account. expected = [ - [[0.091, 0.607], [0.433, 0.933]], - [[0.579, 0.607], [0.922, 0.933]], - [[0.091, 0.140], [0.433, 0.466]], - [[0.579, 0.140], [0.922, 0.466]], + [[0.092, 0.605], [0.433, 0.933]], + [[0.581, 0.605], [0.922, 0.933]], + [[0.092, 0.138], [0.433, 0.466]], + [[0.581, 0.138], [0.922, 0.466]], ] for nn, ax in enumerate(fig.axes): assert_array_equal(np.round(ax.get_position().get_points(), 3), @@ -190,8 +194,8 @@ def add_offsetboxes(ax, size=10, margin=.1, color='black'): """ m, mp = margin, 1+margin anchor_points = [(-m, -m), (-m, .5), (-m, mp), - (mp, .5), (.5, mp), (mp, mp), - (.5, -m), (mp, -m), (.5, -m)] + (.5, mp), (mp, mp), (mp, .5), + (mp, -m), (.5, -m)] for point in anchor_points: da = DrawingArea(size, size) background = Rectangle((0, 0), width=size, @@ -211,47 +215,78 @@ def add_offsetboxes(ax, size=10, margin=.1, color='black'): bbox_transform=ax.transAxes, borderpad=0.) ax.add_artist(anchored_box) - return anchored_box -@image_comparison(['tight_layout_offsetboxes1', 'tight_layout_offsetboxes2']) def test_tight_layout_offsetboxes(): - # 1. + # 0. # - Create 4 subplots # - Plot a diagonal line on them + # - Use tight_layout + # + # 1. + # - Same 4 subplots # - Surround each plot with 7 boxes # - Use tight_layout - # - See that the squares are included in the tight_layout - # and that the squares in the middle do not overlap + # - See that the squares are included in the tight_layout and that the squares do + # not overlap # # 2. - # - Make the squares around the right side axes invisible - # - See that the invisible squares do not affect the - # tight_layout + # - Make the squares around the Axes invisible + # - See that the invisible squares do not affect the tight_layout rows = cols = 2 colors = ['red', 'blue', 'green', 'yellow'] x = y = [0, 1] - def _subplots(): - _, axs = plt.subplots(rows, cols) - axs = axs.flat - for ax, color in zip(axs, colors): + def _subplots(with_boxes): + fig, axs = plt.subplots(rows, cols) + for ax, color in zip(axs.flat, colors): ax.plot(x, y, color=color) - add_offsetboxes(ax, 20, color=color) - return axs + if with_boxes: + add_offsetboxes(ax, 20, color=color) + return fig, axs + + # 0. + fig0, axs0 = _subplots(False) + fig0.tight_layout() # 1. - axs = _subplots() - plt.tight_layout() + fig1, axs1 = _subplots(True) + fig1.tight_layout() + + # The AnchoredOffsetbox should be added to the bounding of the Axes, causing them to + # be smaller than the plain figure. + for ax0, ax1 in zip(axs0.flat, axs1.flat): + bbox0 = ax0.get_position() + bbox1 = ax1.get_position() + assert bbox1.x0 > bbox0.x0 + assert bbox1.x1 < bbox0.x1 + assert bbox1.y0 > bbox0.y0 + assert bbox1.y1 < bbox0.y1 + + # No AnchoredOffsetbox should overlap with another. + bboxes = [] + for ax1 in axs1.flat: + for child in ax1.get_children(): + if not isinstance(child, AnchoredOffsetbox): + continue + bbox = child.get_window_extent() + for other_bbox in bboxes: + assert not bbox.overlaps(other_bbox) + bboxes.append(bbox) # 2. - axs = _subplots() - for ax in (axs[cols-1::rows]): + fig2, axs2 = _subplots(True) + for ax in axs2.flat: for child in ax.get_children(): if isinstance(child, AnchoredOffsetbox): child.set_visible(False) - - plt.tight_layout() + fig2.tight_layout() + # The invisible AnchoredOffsetbox should not count for tight layout, so it should + # look the same as when they were never added. + for ax0, ax2 in zip(axs0.flat, axs2.flat): + bbox0 = ax0.get_position() + bbox2 = ax2.get_position() + assert_array_equal(bbox2.get_points(), bbox0.get_points()) def test_empty_layout(): diff --git a/lib/mpl_toolkits/axisartist/tests/baseline_images/test_axislines/axisline_style_tight.png b/lib/mpl_toolkits/axisartist/tests/baseline_images/test_axislines/axisline_style_tight.png index 77314c1695a0..3b2b80f1f678 100644 Binary files a/lib/mpl_toolkits/axisartist/tests/baseline_images/test_axislines/axisline_style_tight.png and b/lib/mpl_toolkits/axisartist/tests/baseline_images/test_axislines/axisline_style_tight.png differ diff --git a/lib/mpl_toolkits/axisartist/tests/test_axislines.py b/lib/mpl_toolkits/axisartist/tests/test_axislines.py index b722316a5c0c..8bc3707421b6 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_axislines.py +++ b/lib/mpl_toolkits/axisartist/tests/test_axislines.py @@ -119,7 +119,7 @@ def test_axisline_style_size_color(): @image_comparison(['axisline_style_tight.png'], remove_text=True, style='mpl20') def test_axisline_style_tight(): - fig = plt.figure(figsize=(2, 2)) + fig = plt.figure(figsize=(2, 2), layout='tight') ax = fig.add_subplot(axes_class=AxesZero) ax.axis["xzero"].set_axisline_style("-|>", size=5, facecolor='g') ax.axis["xzero"].set_visible(True) @@ -129,8 +129,6 @@ def test_axisline_style_tight(): for direction in ("left", "right", "bottom", "top"): ax.axis[direction].set_visible(False) - fig.tight_layout() - @image_comparison(['subplotzero_ylabel.png'], style='mpl20') def test_subplotzero_ylabel(): 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