From 1964eabe79c5091193c7a54dee9ba61701302ebe Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 13:39:24 -0700 Subject: [PATCH 1/7] Added test for Axes.hexbin (matplotlib#27431) --- lib/matplotlib/tests/test_datetime.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 529244c9656b..456d899c0900 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -433,11 +433,16 @@ def test_fill_betweenx(self): ax2.fill_betweenx(y_dates, x_values1, x_values2) ax3.fill_betweenx(y_dates, x_dates1, x_dates2) - @pytest.mark.xfail(reason="Test for hexbin not written yet") @mpl.style.context("default") def test_hexbin(self): + np.random.seed(19680801) + dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), + np.timedelta64(1, 'D')) fig, ax = plt.subplots() - ax.hexbin(...) + + n = dates.shape + y = np.random.standard_normal(n) + ax.hexbin(dates, y, gridsize=10) @mpl.style.context("default") def test_hist(self): From 6d5038f6d79b1df2bd2837973d3df0593b22c151 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 14:16:30 -0700 Subject: [PATCH 2/7] Added test for Axes.hexbin (matplotlib#27431) --- lib/matplotlib/tests/test_datetime.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 456d899c0900..9d07c8fefff5 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -438,11 +438,13 @@ def test_hexbin(self): np.random.seed(19680801) dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), np.timedelta64(1, 'D')) - fig, ax = plt.subplots() + fig, (ax0, ax1, ax2) = plt.subplots(3, 1, constrained_layout=True) n = dates.shape y = np.random.standard_normal(n) - ax.hexbin(dates, y, gridsize=10) + ax0.hexbin(dates, y, gridsize=10) + ax1.hexbin(dates, y, gridsize=10) + ax2.hexbin(dates, y, gridsize=10) @mpl.style.context("default") def test_hist(self): From c6cae1bdd4b8d7c07228be63cc43bf473597c35a Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 14:33:00 -0700 Subject: [PATCH 3/7] Added test for Axes.hexbin (matplotlib#27431), with additional plots. --- lib/matplotlib/tests/test_datetime.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 9d07c8fefff5..cf9c01395de5 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -436,15 +436,18 @@ def test_fill_betweenx(self): @mpl.style.context("default") def test_hexbin(self): np.random.seed(19680801) + dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), np.timedelta64(1, 'D')) - fig, (ax0, ax1, ax2) = plt.subplots(3, 1, constrained_layout=True) + fig, (ax0, ax1, ax2) = plt.subplots(3, 1) + fig.set_size_inches(4, 8) n = dates.shape + x = np.random.standard_normal(n) y = np.random.standard_normal(n) - ax0.hexbin(dates, y, gridsize=10) - ax1.hexbin(dates, y, gridsize=10) - ax2.hexbin(dates, y, gridsize=10) + ax0.hexbin(dates, y, gridsize=(5, 3)) + ax1.hexbin(x, dates, gridsize=(5, 3)) + ax2.hexbin(dates, dates, gridsize=(5, 3)) @mpl.style.context("default") def test_hist(self): From 231c99f904324457b4d257b43fb7c0c7a90fd623 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 14:45:54 -0700 Subject: [PATCH 4/7] Added test for Axes.hexbin (matplotlib#27431), with additional plots, added mpl.rcParams to clean up axes labelling. --- lib/matplotlib/tests/test_datetime.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index cf9c01395de5..8288c4379c38 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -435,6 +435,8 @@ def test_fill_betweenx(self): @mpl.style.context("default") def test_hexbin(self): + + mpl.rcParams["date.converter"] = 'concise' np.random.seed(19680801) dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), @@ -748,6 +750,7 @@ def test_tricontourf(self): @pytest.mark.xfail(reason="Test for tripcolor not written yet") @mpl.style.context("default") def test_tripcolor(self): + mpl.rcParams["date.converter"] = 'concise' fig, ax = plt.subplots() ax.tripcolor(...) From d35c29e9ecbdd096683ed0d2afdb014361deb211 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 15:26:05 -0700 Subject: [PATCH 5/7] accidentally removed the mpl.rcParams from test_hexbin --- lib/matplotlib/tests/test_datetime.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 8288c4379c38..01a2e4bf32c2 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -435,8 +435,7 @@ def test_fill_betweenx(self): @mpl.style.context("default") def test_hexbin(self): - - mpl.rcParams["date.converter"] = 'concise' + mpl.rcParams["date.converter"] = "concise" np.random.seed(19680801) dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), From 1f880d5c7648404d106e2f7f695e9ffeb895e979 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Fri, 8 Dec 2023 15:29:09 -0700 Subject: [PATCH 6/7] removed mpl.rcParams from test_tripcolor --- lib/matplotlib/tests/test_datetime.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 01a2e4bf32c2..d052f356ed79 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -749,7 +749,6 @@ def test_tricontourf(self): @pytest.mark.xfail(reason="Test for tripcolor not written yet") @mpl.style.context("default") def test_tripcolor(self): - mpl.rcParams["date.converter"] = 'concise' fig, ax = plt.subplots() ax.tripcolor(...) From ce15f4da6d88ca87d39944ebf2bef6ec52906f73 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Sat, 9 Dec 2023 20:03:13 -0700 Subject: [PATCH 7/7] Issue #26864 test_hexbin added extent and marginals, modified gridsize --- lib/matplotlib/tests/test_datetime.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index d052f356ed79..b9697993d3bd 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -435,7 +435,7 @@ def test_fill_betweenx(self): @mpl.style.context("default") def test_hexbin(self): - mpl.rcParams["date.converter"] = "concise" + mpl.rcParams["date.converter"] = 'concise' np.random.seed(19680801) dates = np.arange(np.datetime64('2022-01-01'), np.datetime64('2023-12-31'), @@ -443,12 +443,15 @@ def test_hexbin(self): fig, (ax0, ax1, ax2) = plt.subplots(3, 1) fig.set_size_inches(4, 8) - n = dates.shape + n = dates.shape[0] x = np.random.standard_normal(n) y = np.random.standard_normal(n) - ax0.hexbin(dates, y, gridsize=(5, 3)) - ax1.hexbin(x, dates, gridsize=(5, 3)) - ax2.hexbin(dates, dates, gridsize=(5, 3)) + ax0.hexbin(dates, y, marginals=True, gridsize=(10, 6), + extent=[19030, 19680, min(y), max(y)]) + ax1.hexbin(x, dates, marginals=True, gridsize=(10, 6), + extent=[min(x), max(x), 19030, 19680]) + ax2.hexbin(dates, dates, marginals=True, gridsize=(10, 6), + extent=[19030, 19900, 19030, 19680]) @mpl.style.context("default") def test_hist(self):