Skip to content

Commit 4e45a67

Browse files
author
Shriya Kalakata
committed
Add test_eventplot to test_datetime.py
1 parent 4524fdb commit 4e45a67

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,36 @@ def test_errorbar(self):
260260
uplims=True, xuplims=True,
261261
label='Data')
262262

263-
@pytest.mark.xfail(reason="Test for eventplot not written yet")
264263
@mpl.style.context("default")
265264
def test_eventplot(self):
266-
fig, ax = plt.subplots()
267-
ax.eventplot(...)
265+
mpl.rcParams["date.converter"] = "concise"
266+
267+
fig, (ax1, ax2) = plt.subplots(2, 1, layout="constrained")
268+
269+
x_dates1 = np.array([
270+
datetime.datetime(2020, 6, 30),
271+
datetime.datetime(2020, 7, 22),
272+
datetime.datetime(2020, 8, 3),
273+
datetime.datetime(2020, 9, 14),
274+
], dtype=np.datetime64)
275+
276+
ax1.eventplot(x_dates1)
277+
278+
x_dates2 = np.array([
279+
[datetime.datetime(2020, 6, 30), datetime.datetime(2020, 7, 22),
280+
datetime.datetime(2020, 8, 3), datetime.datetime(2020, 9, 14)],
281+
[datetime.datetime(2020, 7, 18), datetime.datetime(2020, 7, 21),
282+
datetime.datetime(2020, 8, 3), datetime.datetime(2020, 10, 14)]
283+
], dtype=np.datetime64)
284+
285+
colors = ['C{}'.format(i) for i in range(2)]
286+
lineoffsets = np.array([1, 6])
287+
linelengths = [5, 2]
288+
289+
ax2.eventplot(x_dates2,
290+
colors=colors,
291+
lineoffsets=lineoffsets,
292+
linelengths=linelengths)
268293

269294
@pytest.mark.xfail(reason="Test for fill not written yet")
270295
@mpl.style.context("default")

0 commit comments

Comments
 (0)