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

Skip to content

Commit 8be243c

Browse files
authored
Add test_bxp in test_datetime.py (matplotlib#27390)
* added test case for test_bxp * adding datetime functionality * removing plt.show()
1 parent 2ccc703 commit 8be243c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,24 @@ def test_broken_barh(self):
237237
(datetime.datetime(2023, 1, 4), datetime.timedelta(days=4))],
238238
(20, 9), facecolors=('tab:red'))
239239

240-
@pytest.mark.xfail(reason="Test for bxp not written yet")
241240
@mpl.style.context("default")
242241
def test_bxp(self):
242+
mpl.rcParams["date.converter"] = 'concise'
243243
fig, ax = plt.subplots()
244-
ax.bxp(...)
244+
data = [{
245+
"med": datetime.datetime(2020, 1, 15),
246+
"q1": datetime.datetime(2020, 1, 10),
247+
"q3": datetime.datetime(2020, 1, 20),
248+
"whislo": datetime.datetime(2020, 1, 5),
249+
"whishi": datetime.datetime(2020, 1, 25),
250+
"fliers": [
251+
datetime.datetime(2020, 1, 3),
252+
datetime.datetime(2020, 1, 27)
253+
]
254+
}]
255+
ax.bxp(data, vert=False)
256+
ax.xaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d"))
257+
ax.set_title('Box plot with datetime data')
245258

246259
@pytest.mark.xfail(reason="Test for clabel not written yet")
247260
@mpl.style.context("default")

0 commit comments

Comments
 (0)