From 021d6c91de593220d8888e5e3a151099fbbaabde Mon Sep 17 00:00:00 2001 From: rupink Date: Fri, 1 Dec 2023 11:54:01 -0500 Subject: [PATCH 1/2] Added test_hist2d --- lib/matplotlib/tests/test_datetime.py | 41 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 83f1aee4f8bb..1982d19d619a 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -355,12 +355,47 @@ def test_hist(self): weights=values3 ) - @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") def test_hist2d(self): - fig, ax = plt.subplots() - ax.hist2d(...) + mpl.rcParams["date.converter"] = 'concise' + + start_date = datetime.datetime(2023, 10, 1) + time_delta = datetime.timedelta(days=1) + + values1 = np.random.randint(1, 10, 30) + values2 = np.random.randint(1, 10, 30) + values3 = np.random.randint(1, 10, 30) + + x_values = mpl.dates.date2num([start_date + i * time_delta for i in range(30)]) + # Using Axes.hist2d + fig, (ax1, ax2, ax3) = plt.subplots(1, 3, constrained_layout=True) + + # Testing with Axes.hist2d + hist2d1 = ax1.hist2d( + x_values, + values1, + bins=10, + cmap='Blues' + ) + ax1.set_title('Axes.hist2d - Data 1') + + hist2d2 = ax2.hist2d( + x_values, + values2, + bins=10, + cmap='Greens' + ) + ax2.set_title('Axes.hist2d - Data 2') + + hist2d3 = ax3.hist2d( + x_values, + values3, + bins=10, + cmap='Reds' + ) + ax3.set_title('Axes.hist2d - Data 3') + @mpl.style.context("default") def test_hlines(self): mpl.rcParams["date.converter"] = 'concise' From ef7482a52825df5e67c9a02226b4d5a51b8f043d Mon Sep 17 00:00:00 2001 From: rupink <66811124+rupink@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:54:54 -0500 Subject: [PATCH 2/2] Update lib/matplotlib/tests/test_datetime.py Co-authored-by: Kyle Sunden --- 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 1982d19d619a..28c90032e359 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -395,7 +395,6 @@ def test_hist2d(self): cmap='Reds' ) ax3.set_title('Axes.hist2d - Data 3') - @mpl.style.context("default") def test_hlines(self): mpl.rcParams["date.converter"] = 'concise' 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