Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c543e4f

Browse files
Add test_vlines to test_datetime.py
1 parent ac74b74 commit c543e4f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,28 @@ def test_violinplot(self):
612612
fig, ax = plt.subplots()
613613
ax.violinplot(...)
614614

615-
@pytest.mark.xfail(reason="Test for vlines not written yet")
616615
@mpl.style.context("default")
617616
def test_vlines(self):
618-
fig, ax = plt.subplots()
619-
ax.vlines(...)
617+
mpl.rcParams["date.converter"] = 'concise'
618+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout='constrained')
619+
dates = [datetime.datetime(2023, 2, 10),
620+
datetime.datetime(2023, 5, 18),
621+
datetime.datetime(2023, 6, 6)]
622+
ax1.set_xlim(left=datetime.datetime(2023, 1, 1),
623+
right=datetime.datetime(2023, 6, 30))
624+
ax1.vlines(x=dates,
625+
ymin=[0, 0.25, 0.5],
626+
ymax=[0.25, 0.5, 0.75])
627+
ax2.set_xlim(left=0,
628+
right=0.5)
629+
ax2.vlines(x=[0.3, 0.35],
630+
ymin=[np.datetime64('2023-03-20'), np.datetime64('2023-03-31')],
631+
ymax=[np.datetime64('2023-05-01'), np.datetime64('2023-05-16')])
632+
ax3.set_xlim(left=datetime.datetime(2023, 7, 1),
633+
right=datetime.datetime(2023, 12, 31))
634+
ax3.vlines(x=[datetime.datetime(2023, 9, 1), datetime.datetime(2023, 12, 10)],
635+
ymin=datetime.datetime(2023, 1, 15),
636+
ymax=datetime.datetime(2023, 1, 30))
620637

621638
@pytest.mark.xfail(reason="Test for xcorr not written yet")
622639
@mpl.style.context("default")

0 commit comments

Comments
 (0)