8000 Added test_fill_betweenx in test_datetime.py (#27425) · matplotlib/matplotlib@41afb90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41afb90

Browse files
xieruoyiRuoyi
andauthored
Added test_fill_betweenx in test_datetime.py (#27425)
* Added test for fill_betweenx * pull the newest update * Deleted the second figure and only leave datetime figures --------- Co-authored-by: Ruoyi <ruoyi.xie@mail.utoronto.ca>
1 parent d69c415 commit 41afb90

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,40 @@ def test_fill_between(self):
389389
ax2.fill_between(x_dates, y_values1, y_values2)
390390
ax3.fill_between(x_dates, y_dates1, y_dates2)
391391

392-
@pytest.mark.xfail(reason="Test for fill_betweenx not written yet")
393392
@mpl.style.context("default")
394393
def test_fill_betweenx(self):
395-
fig, ax = plt.subplots()
396-
ax.fill_betweenx(...)
394+
mpl.rcParams["date.converter"] = "concise"
395+
np.random.seed(19680801)
396+
397+
x_base_date = datetime.datetime(2023, 1, 1)
398+
x_dates1 = [x_base_date]
399+
for i in range(1, 10):
400+
x_base_date += datetime.timedelta(days=np.random.randint(1, 5))
401+
x_dates1.append(x_base_date)
402+
403+
x_dates2 = [x_base_date]
404+
for i in range(1, 10):
405+
x_base_date += datetime.timedelta(days=np.random.randint(1, 5))
406+
x_dates2.append(x_base_date)
407+
y_values = np.random.rand(10) * 10
408+
y_values.sort()
409+
410+
x_values1 = np.random.rand(10) * 10
411+
x_values2 = x_values1 + np.random.rand(10) * 10
412+
x_values1.sort()
413+
x_values2.sort()
414+
415+
y_base_date = datetime.datetime(2023, 1, 1)
416+
y_dates = [y_base_date]
417+
for i in range(1, 10):
418+
y_base_date += datetime.timedelta(days=np.random.randint(1, 10))
419+
y_dates.append(y_base_date)
420+
421+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, layout="constrained")
422+
423+
ax1.fill_betweenx(y_values, x_dates1, x_dates2)
424+
ax2.fill_betweenx(y_dates, x_values1, x_values2)
425+
ax3.fill_betweenx(y_dates, x_dates1, x_dates2)
397426

398427
@pytest.mark.xfail(reason="Test for hexbin not written yet")
399428
@mpl.style.context("default")

0 commit comments

Comments
 (0)
0