From 74f562d6fbecfd7625d81e23b1a7cdf0f989cb41 Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:47:27 -0700 Subject: [PATCH 1/8] test_axes added 3 subplots with datetime array on the x axis, y axis, and both axes. --- lib/matplotlib/tests/test_datetime.py | 42 +++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 53958229f174..491d47f5aab2 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -279,9 +279,45 @@ def test_quiverkey(self): @pytest.mark.xfail(reason="Test for scatter not written yet") @mpl.style.context("default") def test_scatter(self): - fig, ax = plt.subplots() - ax.scatter(...) - + mpl.rcParams["date.converter"] = 'concise' + base = datetime.datetime(2005, 2, 1) + dates = [base + datetime.timedelta(hours=(2 * i)) for i in range(732)] + N = len(dates) + np.random.seed(19680801) + y = np.cumsum(np.random.randn(N)) + + fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6)) + lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), + (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), + (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] + + axs[0].set_title('Axes.scatter used with datetime on x axis') + + for elem in axs: + print (elem) + + #datetime on x axis + axs[0].scatter(dates, y) + #axs[0].set_xlim(lims[nn]) + # rotate_labels... + for label in axs[0].get_xticklabels(): + label.set_rotation(40) + label.set_horizontalalignment('right') + + #datetime on y axis + axs[1].set_title('Axes.scatter used with datetime on y axis') + axs[1].scatter(y, dates) + for label in axs[1].get_xticklabels(): + label.set_rotation(40) + label.set_horizontalalignment('right') + + #datetime on both x, y axes + axs[2].set_title('Axes.scatter used with datetime on both axes') + axs[2].scatter(dates, dates) + for label in axs[2].get_xticklabels(): + label.set_rotation(40) + label.set_horizontalalignment('right') + @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") def test_semilogx(self): From e5790baa8d3bfe91dc08d5b989b04cfbf5affec6 Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:14:49 -0700 Subject: [PATCH 2/8] incorporated issues in previous PR --- lib/matplotlib/tests/test_datetime.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 491d47f5aab2..bf04e4c5046c 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -276,7 +276,6 @@ def test_quiverkey(self): fig, ax = plt.subplots() ax.quiverkey(...) - @pytest.mark.xfail(reason="Test for scatter not written yet") @mpl.style.context("default") def test_scatter(self): mpl.rcParams["date.converter"] = 'concise' @@ -285,39 +284,31 @@ def test_scatter(self): N = len(dates) np.random.seed(19680801) y = np.cumsum(np.random.randn(N)) - fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6)) lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] - axs[0].set_title('Axes.scatter used with datetime on x axis') - - for elem in axs: - print (elem) - - #datetime on x axis + # datetime array on x axis axs[0].scatter(dates, y) - #axs[0].set_xlim(lims[nn]) - # rotate_labels... + # rotate labels so they don't look clogged for label in axs[0].get_xticklabels(): label.set_rotation(40) label.set_horizontalalignment('right') - - #datetime on y axis + # datetime on y axis axs[1].set_title('Axes.scatter used with datetime on y axis') axs[1].scatter(y, dates) + # rotate labels so they don't look clogged for label in axs[1].get_xticklabels(): label.set_rotation(40) label.set_horizontalalignment('right') - - #datetime on both x, y axes + # datetime on both x, y axes axs[2].set_title('Axes.scatter used with datetime on both axes') axs[2].scatter(dates, dates) for label in axs[2].get_xticklabels(): label.set_rotation(40) label.set_horizontalalignment('right') - + @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") def test_semilogx(self): From 99648b028a4030e22a57dd4961d1a09728033a59 Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:20:07 -0700 Subject: [PATCH 3/8] deleted whitespaces after end of line --- lib/matplotlib/tests/test_datetime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index bf04e4c5046c..ff057e66c1b9 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -295,7 +295,7 @@ def test_scatter(self): for label in axs[0].get_xticklabels(): label.set_rotation(40) label.set_horizontalalignment('right') - # datetime on y axis + # datetime on y axis axs[1].set_title('Axes.scatter used with datetime on y axis') axs[1].scatter(y, dates) # rotate labels so they don't look clogged @@ -307,7 +307,7 @@ def test_scatter(self): axs[2].scatter(dates, dates) for label in axs[2].get_xticklabels(): label.set_rotation(40) - label.set_horizontalalignment('right') + label.set_horizontalalignment('right') @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") From 9c85d6aa6fc99c390f7b29ed1c4a3459f4b0fded Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:29:04 -0700 Subject: [PATCH 4/8] got rid of space in 311 --- 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 ff057e66c1b9..bad8529ec869 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -308,7 +308,7 @@ def test_scatter(self): for label in axs[2].get_xticklabels(): label.set_rotation(40) label.set_horizontalalignment('right') - + @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") def test_semilogx(self): From 9a3c608235514cf0fcd1f2a9ba8d57dd8372e69a Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:08:11 -0700 Subject: [PATCH 5/8] Simplified datetime array --- lib/matplotlib/tests/test_datetime.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index bad8529ec869..9a7eb5127e08 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -280,34 +280,20 @@ def test_quiverkey(self): def test_scatter(self): mpl.rcParams["date.converter"] = 'concise' base = datetime.datetime(2005, 2, 1) - dates = [base + datetime.timedelta(hours=(2 * i)) for i in range(732)] N = len(dates) np.random.seed(19680801) y = np.cumsum(np.random.randn(N)) fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6)) - lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), + dates = [(np.datetime64('2005-02'), np.datetime64('2005-04')), (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] axs[0].set_title('Axes.scatter used with datetime on x axis') # datetime array on x axis axs[0].scatter(dates, y) - # rotate labels so they don't look clogged - for label in axs[0].get_xticklabels(): - label.set_rotation(40) - label.set_horizontalalignment('right') # datetime on y axis - axs[1].set_title('Axes.scatter used with datetime on y axis') axs[1].scatter(y, dates) - # rotate labels so they don't look clogged - for label in axs[1].get_xticklabels(): - label.set_rotation(40) - label.set_horizontalalignment('right') # datetime on both x, y axes - axs[2].set_title('Axes.scatter used with datetime on both axes') axs[2].scatter(dates, dates) - for label in axs[2].get_xticklabels(): - label.set_rotation(40) - label.set_horizontalalignment('right') @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") From b46f6d1aa668ce0614cec12292bbad87dd1cadc0 Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:10:00 -0700 Subject: [PATCH 6/8] fixed mistake in previous commit --- lib/matplotlib/tests/test_datetime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 9a7eb5127e08..bd7b3e00576d 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -280,11 +280,12 @@ def test_quiverkey(self): def test_scatter(self): mpl.rcParams["date.converter"] = 'concise' base = datetime.datetime(2005, 2, 1) + dates = [base + datetime.timedelta(hours=(2 * i)) for i in range(10)] N = len(dates) np.random.seed(19680801) y = np.cumsum(np.random.randn(N)) fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6)) - dates = [(np.datetime64('2005-02'), np.datetime64('2005-04')), + lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] axs[0].set_title('Axes.scatter used with datetime on x axis') From b16472c950f73ba855d52a1bfa90c1de8df77115 Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:15:46 -0700 Subject: [PATCH 7/8] Update test_datetime.py I needed to rotate axis labels because they were still clogged after I reduced array length --- lib/matplotlib/tests/test_datetime.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index bd7b3e00576d..ce41f4fccf5f 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -288,13 +288,18 @@ def test_scatter(self): lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] - axs[0].set_title('Axes.scatter used with datetime on x axis') # datetime array on x axis axs[0].scatter(dates, y) + for label in axs[0].get_xticklabels(): + label.set_rotation(40) + label.set_horizontalalignment('right') # datetime on y axis axs[1].scatter(y, dates) # datetime on both x, y axes axs[2].scatter(dates, dates) + for label in axs[2].get_xticklabels(): + label.set_rotation(40) + label.set_horizontalalignment('right') @pytest.mark.xfail(reason="Test for semilogx not written yet") @mpl.style.context("default") From 7c6eeef9913e0db307659525f2eacfb38ca222ed Mon Sep 17 00:00:00 2001 From: Seohyeon Lee <96499556+seohyeon-lee-2025@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:01:30 -0700 Subject: [PATCH 8/8] Update test_datetime.py eliminated unused variable according to feedback ('lims') --- lib/matplotlib/tests/test_datetime.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index e67830db602a..05c1260f3dac 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -297,9 +297,6 @@ def test_scatter(self): np.random.seed(19680801) y = np.cumsum(np.random.randn(N)) fig, axs = plt.subplots(3, 1, layout='constrained', figsize=(6, 6)) - lims = [(np.datetime64('2005-02'), np.datetime64('2005-04')), - (np.datetime64('2005-02-03'), np.datetime64('2005-02-15')), - (np.datetime64('2005-02-03 11:00'), np.datetime64('2005-02-04 13:20'))] # datetime array on x axis axs[0].scatter(dates, y) for label in axs[0].get_xticklabels(): 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