8000 Add test_hlines to test_datetimes.py · matplotlib/matplotlib@71e1c63 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71e1c63

Browse files
committed
Add test_hlines to test_datetimes.py
1 parent a589856 commit 71e1c63

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,27 @@ def test_hist2d(self):
218218
fig, ax = plt.subplots()
219219
ax.hist2d(...)
220220

221-
@pytest.mark.xfail(reason="Test for hlines not written yet")
222221
@mpl.style.context("default")
223222
def test_hlines(self):
224-
fig, ax = plt.subplots()
225-
ax.hlines(...)
223+
mpl.rcParams["date.converter"] = 'concise'
224+
fig, axs = plt.subplots(2, 3, layout='constrained')
225+
dateStrs = ['2023-03-08',
226+
'2023-04-09',
227+
'2023-05-13',
228+
'2023-07-28',
229+
'2023-12-24']
230+
dates = [datetime.datetime(2023, m*2, 10) for m in range(1, 6)]
231+
npDates = [np.datetime64(s) for s in dateStrs]
232+
axs[0, 0].hlines(y=dates,
233+
xmin=[0.1, 0.2, 0.3, 0.4, 0.5],
234+
xmax=[0.5, 0.6, 0.7, 0.8, 0.9])
235+
axs[0, 1].hlines(y=dates, xmin=0.2, xmax=0.8)
236+
axs[0, 2].hlines(dates, xmin=0, xmax=1)
237+
axs[1, 0].hlines(y=npDates,
238+
xmin=[0.5, 0.6, 0.7, 0.8, 0.9],
239+
xmax=[0.1, 0.2, 0.3, 0.4, 0.5])
240+
axs[1, 1].hlines(y=npDates, xmin=0.45, xmax=0.65)
241+
axs[1, 2].hlines(npDates, xmin=0, xmax=1)
226242

227243
@pytest.mark.xfail(reason="Test for imshow not written yet")
228244
@mpl.style.context("default")

0 commit comments

Comments
 (0)
0