From 8c55381236ca74e67874ed31fe7ae93dd63da047 Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Mon, 23 Oct 2023 12:08:20 -0400 Subject: [PATCH 1/4] Add test_axhline in test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index c9455d450b70..7c188420d91f 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -29,8 +29,20 @@ def test_arrow(self): @pytest.mark.xfail(reason="Test for axhline not written yet") @mpl.style.context("default") def test_axhline(self): - fig, ax = plt.subplots() - ax.axhline(...) + mpl.rcParams["date.converter"] = 'concise' + fig, ax = plt.subplots(layout='constrained') + birth_date = np.array([datetime.datetime(2020, 4, 10), + datetime.datetime(2020, 5, 30), + datetime.datetime(2020, 10, 12), + datetime.datetime(2020, 11, 15)]) + year_start = datetime.datetime(2020, 1, 1) + year_end = datetime.datetime(2020, 12, 31) + age = [21, 53, 20, 24] + ax.set_xlabel('Birth Date') + ax.set_ylabel('Age') + ax.set_ylim(bottom=year_start, top=year_end) + ax.bar(x=age, height=birth_date) + ax.axhline(y=datetime.datetime(2020, 6, 1)) @pytest.mark.xfail(reason="Test for axhspan not written yet") @mpl.style.context("default") From 0c2f104457fd10c0dc69bc760bba654c257d4e16 Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Tue, 24 Oct 2023 14:15:26 -0400 Subject: [PATCH 2/4] Simplified example code and added arguments for xmin and xmax --- lib/matplotlib/tests/test_datetime.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 7c188420d91f..1aafa437e98e 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -31,18 +31,7 @@ def test_arrow(self): def test_axhline(self): mpl.rcParams["date.converter"] = 'concise' fig, ax = plt.subplots(layout='constrained') - birth_date = np.array([datetime.datetime(2020, 4, 10), - datetime.datetime(2020, 5, 30), - datetime.datetime(2020, 10, 12), - datetime.datetime(2020, 11, 15)]) - year_start = datetime.datetime(2020, 1, 1) - year_end = datetime.datetime(2020, 12, 31) - age = [21, 53, 20, 24] - ax.set_xlabel('Birth Date') - ax.set_ylabel('Age') - ax.set_ylim(bottom=year_start, top=year_end) - ax.bar(x=age, height=birth_date) - ax.axhline(y=datetime.datetime(2020, 6, 1)) + ax.axhline(y=datetime.datetime(2020, 6, 1), xmin=0.2, xmax=0.8) @pytest.mark.xfail(reason="Test for axhspan not written yet") @mpl.style.context("default") From 875b441f54efe1b773acfd319fdbeec0ee771ecf Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Tue, 24 Oct 2023 16:58:56 -0400 Subject: [PATCH 3/4] Add test_axhline in test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 1aafa437e98e..79389e818e71 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -26,12 +26,18 @@ def test_arrow(self): fig, ax = plt.subplots() ax.arrow(...) - @pytest.mark.xfail(reason="Test for axhline not written yet") @mpl.style.context("default") def test_axhline(self): mpl.rcParams["date.converter"] = 'concise' - fig, ax = plt.subplots(layout='constrained') - ax.axhline(y=datetime.datetime(2020, 6, 1), xmin=0.2, xmax=0.8) + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout='constrained') + ax1.set_ylim(bottom=datetime.datetime(2020, 4, 1), + top=datetime.datetime(2020, 8, 1)) + ax2.set_ylim(bottom=np.datetime64('2005-01-01'), + top=np.datetime64('2005-04-01')) + ax3.set_ylim(bottom=datetime.datetime(2023, 9, 1), + top=datetime.datetime(2023, 11, 1)) + ax1.axhline(y=datetime.datetime(2020, 6, 3), xmin=0.5, xmax=0.7) + ax2.axhline(np.datetime64('2005-02-25T03:30'), xmin=0.1, xmax=0.9) @pytest.mark.xfail(reason="Test for axhspan not written yet") @mpl.style.context("default") From f319e356af49381b29b7c7da63f1ddd5ce717398 Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Thu, 26 Oct 2023 13:20:55 -0400 Subject: [PATCH 4/4] Add axhline to ax3 --- lib/matplotlib/tests/test_datetime.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 79389e818e71..a8b6bcee3bd4 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -38,6 +38,7 @@ def test_axhline(self): top=datetime.datetime(2023, 11, 1)) ax1.axhline(y=datetime.datetime(2020, 6, 3), xmin=0.5, xmax=0.7) ax2.axhline(np.datetime64('2005-02-25T03:30'), xmin=0.1, xmax=0.9) + ax3.axhline(y=datetime.datetime(2023, 10, 24), xmin=0.4, xmax=0.7) @pytest.mark.xfail(reason="Test for axhspan not written yet") @mpl.style.context("default") 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