From 9693cf900be77b1a35faba411b597cb0e472d2e9 Mon Sep 17 00:00:00 2001 From: samchan2022 Date: Mon, 27 Nov 2023 01:26:09 +0000 Subject: [PATCH] add test arrow --- lib/matplotlib/tests/test_datetime.py | 56 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 316be793e47c..a461a039f4e6 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -20,11 +20,61 @@ 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(x=dates[10], + y=10, + dx=10, + dy=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(x=10, + y=dates[10], + dx=10, + dy=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(x=dates[10], + y=dates[10], + dx=10, + dy=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