Skip to content

Commit 8c55381

Browse files
committed
Add test_axhline in test_datetime.py
1 parent a589856 commit 8c55381

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@ def test_arrow(self):
2929
@pytest.mark.xfail(reason="Test for axhline not written yet")
3030
@mpl.style.context("default")
3131
def test_axhline(self):
32-
fig, ax = plt.subplots()
33-
ax.axhline(...)
32+
mpl.rcParams["date.converter"] = 'concise'
33+
fig, ax = plt.subplots(layout='constrained')
34+
birth_date = np.array([datetime.datetime(2020, 4, 10),
35+
datetime.datetime(2020, 5, 30),
36+
datetime.datetime(2020, 10, 12),
37+
datetime.datetime(2020, 11, 15)])
38+
year_start = datetime.datetime(2020, 1, 1)
39+
year_end = datetime.datetime(2020, 12, 31)
40+
age = [21, 53, 20, 24]
41+
ax.set_xlabel('Birth Date')
42+
ax.set_ylabel('Age')
43+
ax.set_ylim(bottom=year_start, top=year_end)
44+
ax.bar(x=age, height=birth_date)
45+
ax.axhline(y=datetime.datetime(2020, 6, 1))
3446

3547
@pytest.mark.xfail(reason="Test for axhspan not written yet")
3648
@mpl.style.context("default")

0 commit comments

Comments
 (0)