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

Skip to content

Commit 00c8072

Browse files
Add test_vlines to test_datetime.py
1 parent 62a5ba4 commit 00c8072

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
@@ -600,11 +600,28 @@ def test_violinplot(self):
600600
fig, ax = plt.subplots()
601601
ax.violinplot(...)
602602

603-
@pytest.mark.xfail(reason="Test for vlines not written yet")
604603
@mpl.style.context("default")
605604
def test_vlines(self):
606-
fig, ax = plt.subplots()
607-
ax.vlines(...)
605+
mpl.rcParams["date.converter"] = 'concise'
606+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout='constrained')
607+
dates = [datetime.datetime(2023, 2, 10),
608+
datetime.datetime(2023, 5, 18),
609+
datetime.datetime(2023, 6, 6)]
610+
ax1.set_xlim(left=datetime.datetime(2023, 1, 1),
611+
right=datetime.datetime(2023, 6, 30))
612+
ax2.set_xlim(left=0,
613+
right=0.5)
614+
ax3.set_xlim(left=datetime.datetime(2023, 7, 1),
615+
right=datetime.datetime(2023, 12, 31))
616+
ax1.vlines(x=dates,
617+
ymin=[0, 0.25, 0.5],
618+
ymax=[0.25, 0.5, 0.75])
619+
ax2.vlines(x=[0.3, 0.4],
620+
ymin=[np.datetime64('2023-03-20'), np.datetime64('2023-03-31')],
621+
ymax=[np.datetime64('2023-05-01'), np.datetime64('2023-05-16')])
622+
ax3.vlines(x=[datetime.datetime(2023, 9, 1), datetime.datetime(2023, 12, 10)],
623+
ymin=datetime.datetime(2023, 1, 15),
624+
ymax=datetime.datetime(2023, 1, 30))
608625

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

0 commit comments

Comments
 (0)