From ebc744ae347034719eb1e8d33ca9df4c7819921c Mon Sep 17 00:00:00 2001 From: samchan2022 Date: Mon, 27 Nov 2023 21:00:55 +0000 Subject: [PATCH] add test_arrow --- lib/matplotlib/tests/test_datetime.py | 47 +++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 316be793e47c..b623c98bf8cb 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -20,11 +20,52 @@ def test_annotate(self): fig, ax = plt.subplots() ax.annotate(...) - @pytest.mark.xfail(reason="Test for arrow not written yet") @mpl.style.context("default") def test_arrow(self): - fig, ax = plt.subplots() - ax.arrow(...) + mpl.rcParams["date.converter"] = 'concise' + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, + constrained_layout=True, + figsize=(10, 12)) + + start_date = datetime.datetime(2023, 1, 1) + dates = [start_date + datetime.timedelta(days=i) for i in range(31)] + y_values = range(31) + + ax1.plot(dates, y_values, marker='o') + ax1.arrow(dates[10], 10, 10, 10, + head_width=1, + head_length=1, + linewidth=3, + facecolor='red', + edgecolor='red', + transform=ax1.transData) + ax1.set_title('Datetime vs. Number') + ax1.set_xlabel('Date') + ax1.set_ylabel('Number') + + ax2.plot(y_values, dates, marker='o') + ax2.arrow(10, dates[10], 10, 10, + head_width=1, + head_length=1, + linewidth=3, + facecolor='red', + edgecolor='red', + transform=ax2.transData) + ax2.set_title('Number vs. Datetime') + ax2.set_xlabel('Number') + ax2.set_ylabel('Date') + + ax3.plot(dates, dates, marker='o') + ax3.arrow(dates[10], dates[10], 10, 10, + head_width=1, + head_length=1, + linewidth=3, + facecolor='red', + edgecolor='red', + transform=ax3.transData) + ax3.set_title('Datetime vs. Datetime') + ax3.set_xlabel('Date') + ax3.set_ylabel('Date') @mpl.style.context("default") def test_axhline(self): 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