diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 83f1aee4f8bb..28c90032e359 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -355,12 +355,46 @@ 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' 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