From 3fa749b1cad47b014414f33b7b7bbcfc1b16974b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 12 Aug 2025 11:51:13 +0100 Subject: [PATCH 1/2] Add datetime test for ax.violin --- lib/matplotlib/tests/test_datetime.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 821552befcf0..0bed0d6f7ea7 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -810,11 +810,32 @@ def test_triplot(self): fig, ax = plt.subplots() ax.triplot(...) - @pytest.mark.xfail(reason="Test for violin not written yet") + @pytest.mark.parametrize(("orientation"), ["vertical", "horizontal"]) @mpl.style.context("default") - def test_violin(self): + def test_violin(self, orientation): fig, ax = plt.subplots() - ax.violin(...) + datetimes = [ + datetime.datetime(2023, 2, 10), + datetime.datetime(2023, 5, 18), + datetime.datetime(2023, 6, 6) + ] + ax.violin( + [ + { + 'coords': datetimes, + 'vals': [0.1, 0.5, 0.2], + 'mean': datetimes[1], + 'median': datetimes[1], + 'min': datetimes[0], + 'max': datetimes[-1], + 'quantiles': datetimes + } + ], + orientation=orientation, + # TODO: It should be possible for positions to be datetimes too + # https://github.com/matplotlib/matplotlib/issues/30417 + # positions=[datetime.datetime(2020, 1, 1)] + ) @pytest.mark.xfail(reason="Test for violinplot not written yet") @mpl.style.context("default") From 4b1257ddf434e2ba8d25a1fd83ff996c5a291970 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:31:37 +0200 Subject: [PATCH 2/2] Update lib/matplotlib/tests/test_datetime.py Co-authored-by: Elliott Sales de Andrade --- lib/matplotlib/tests/test_datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 0bed0d6f7ea7..b3bd4d7bd151 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -810,7 +810,7 @@ def test_triplot(self): fig, ax = plt.subplots() ax.triplot(...) - @pytest.mark.parametrize(("orientation"), ["vertical", "horizontal"]) + @pytest.mark.parametrize("orientation", ["vertical", "horizontal"]) @mpl.style.context("default") def test_violin(self, orientation): fig, ax = plt.subplots()